单行注释宏扼流圈gcc

hmj*_*hmj 3 c macros gcc comments

atest.c

#define COMMENT /##/

int main()
{
   ...
   COMMENT int atest;
   ...
}
Run Code Online (Sandbox Code Playgroud)

错误消息:

atest.c:16:1: error: pasting "/" and "/" does not give a valid preprocessing token

atest.c: In function 'main':

atest.c:16: error: expected expression before '/' token

虽然Microsoft C编译器对COMMENT宏感到满意.这里的提示也不起作用.

有人可以为此提供解决方案或解释吗?谢谢.

CB *_*ley 8

使用标记粘贴运算符时##,组合两个操作数的结果必须是有效的预处理程序标记.

//不是有效的预处理令牌.删除注释后会发生预处理,因此无法在预处理阶段添加注释.