C99标准文档在与##预处理运算符相关的章节中有以下示例:
我不理解为什么替换hash_hash会产生##而不是"##"或"#""#"。双哈希之前和之后的单哈希扮演了什么角色?In the following fragment:
#define hash_hash # ## # #define mkstr(a) # a #define in_between(a) mkstr(a) #define join(c, d) in_between(c hash_hash d) char p[] = join(x, y); // equivalent to // char p[] = "x ## y";
The expansion produces, at various stages:
join(x, y) in_between(x hash_hash y) in_between(x ## y) mkstr(x ## y) "x ## y"
In other words, expanding hash_hash produces a new token, consisting of two adjacent sharp signs, but this new token is not the ## operator.
非常感谢任何回复。