uli*_*tko 1 c macros c-preprocessor
考虑一下片段:
#define CAT(a, b) a##b #define M_0 CAT(x, y) #define M(a) CAT(M_, a)() M(0); #define N_0() CAT(x, y) #define N(a) CAT(N_, a)() N(0);
对我来说,两个定义M(a)
和N(a)
看起来完全相同.但是,cpp
GCC 4.6.1将其扩展为:
CAT(x, y)(); xy;
为什么?
#define M_0 CAT(x, y)
#define N_0() CAT(x, y)
Run Code Online (Sandbox Code Playgroud)
M_0
是一个简单的文本替换.N_0
是一个宏函数,在评估时,根据需要评估任何其他宏函数.