首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

请问关于GCC的预处理有关问题(宏定义中的#运算符)

2013-02-19 
请教关于GCC的预处理问题(宏定义中的##运算符)本帖最后由 FMadot 于 2013-02-04 21:31:49 编辑在翻阅GCC的

请教关于GCC的预处理问题(宏定义中的##运算符)
本帖最后由 FMadot 于 2013-02-04 21:31:49 编辑 在翻阅GCC的CPP(c preprocessor)文档时,发现一个问题。在提到##这个连接运算符的时候,说“two tokens that don't together form a valid token cannot be pasted together. For example, you cannot concatenate x with + in either order. If you try, the preprocessor issues a warning and emits the two tokens. ”
意思就是如果你定义了一下宏
#define CON(a,b) a##b
如果你以如下方式调用了这个宏CON(x,+),然后编译器会给出错误“链接x和+不能给出一个有效的预处理标识符” 也就是上文中提到的valid token。我想问一下这个valid token到底是指什么 为什么这么连接起来不可以?
[解决办法]
##连接起来后要得到一个标识符,也就是_、字母、数字
但是,有些编译器没有这个限制。

热点排行