宏中的双重哈希(##)是什么意思? [英] What does a double hash (##) in a macro mean?
本文介绍了宏中的双重哈希(##)是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中, ##
是什么?
In the below code, what does the ##
do?
#define MAKE_TYPE(myname) \
typedef int myname ## Id; \
推荐答案
##
在宏中是连接。这里, MAKE_TYPE(test)
将展开为: typedef int testId
。
The ##
in a macro is concatenation. Here, MAKE_TYPE(test)
will expand to : typedef int testId
.
从16.3.3(##运算符):
From 16.3.3 (The ## operator) :
对象式和函数式
宏调用,在
替换列表被重新检查
更多的宏名称替换之前,替换列表中的每个
实例的##预处理令牌
(不是从
参数)被删除,前面的
预处理令牌将
与以下预处理令牌连接起来
For both object-like and function-like macro invocations, before the replacement list is reexamined for more macro names to replace, each instance of a ## preprocessing token in the replacement list (not from an argument) is deleted and the preceding preprocessing token is concatenated with the following preprocessing token
这篇关于宏中的双重哈希(##)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文