Possible Duplicate:
C Preprocessor, Stringify the result of a macro
Shortly:
#include <iostream>
float pi(){ return 3.14; }
#define PRINT(x) std::cout << #x << std::endl;
#define PI pi()
int main(int argc, char *argv[])
{
PRINT(PI)
PRINT(pi())
return 0;
}
Result:
PI
pi()
Is there any way to get only preprocessed data in macro argument? To get as a result
pi()
pi()
?
EDIT:
I haven't noticed this question: C Preprocessor, Stringify the result of a macro Duplicate...
Add another helper macro:
#define QU(x) #x
#define PRINT(x) std::cout << QU(x) << std::endl;
#define PI pi()
精彩评论