[英]How to define function declaration macro
I have the following problem: I need to define a macro that has to be used instead of using regular C expression. 我有以下问题:我需要定义一个必须使用的宏,而不是使用正则C表达式。
For example I want this: 例如我想要这样:
THREAD(FIRST)
... to be substituted by this ...被这个代替
void THREAD_FIRST(void)
... in the code. ...在代码中。
I tried with this: 我尝试了这个:
#define THREAD(x) void THREAD_#x(void)
... but it didn't work. ...但是没有用。 Maybe the space after
void
is not permitted. 也许在
void
之后的void
是不允许的。 Any ideas how to solve it? 有什么想法如何解决吗?
您使用了错误的预处理程序运算符,要使用##
而不是#
进行令牌粘贴
#define THREAD(x) void THREAD_##x (void)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.