[英]C macro ## doesn't work for function definition
#define FUNCXY(x,y) void FUNC_##x_##y(int){}
#define FUNCXYGOOD(x,y) void FUNCGOOD_##x##_##y(int){}
FUNCXY(2, 1) //get expanded to void FUNC_x_1(int){}
FUNCXYGOOD(2, 1) //get expanded to void FUNCGOOD_2_1(int){}
Why doesn't FUNCXY work but FUNCXYGOOD work, that is the C rule behind this?为什么 FUNCXY 不起作用但 FUNCXYGOOD 起作用,这就是这背后的 C 规则?
The answer is very simple.答案很简单。 there is no x_
macro parameter.没有x_
宏参数。 Underscores are part of the macro token.下划线是宏标记的一部分。 Underscore is same as any other valid token character下划线与任何其他有效标记字符相同
Othersise it would be inposibe to have macro like this:其他情况下,像这样的宏是不可能的:
#define FOO(x, xa, xb)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.