#define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
此代码给出输出 100,但如果实现预处理器,printf
将被重写为:
printf("%d",var##12);
那么,输出是怎么来的呢?
最佳答案
双哈希 ##
是 token pasting operator的预处理器。 printf
将被重写为:
printf("%d",var12); // No double-hash
The double-number-sign or "token-pasting" operator (##), which is sometimes called the "merging" operator, is used in both object-like and function-like macros. It permits separate tokens to be joined into a single token and therefore cannot be the first or last token in the macro definition.
关于c - 带有哈希的预处理器指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16739695/