【发布时间】:2010-11-24 10:02:57
【问题描述】:
# 符号在#define 宏中用作变量前缀时是什么意思?
例如,
#define my_setopt(x,y,z) _my_setopt(x, 0, config, #y, y, z)
【问题讨论】:
# 符号在#define 宏中用作变量前缀时是什么意思?
例如,
#define my_setopt(x,y,z) _my_setopt(x, 0, config, #y, y, z)
【问题讨论】:
# 引用表达式。例如:
#define SHOW(BAR) printf("%s is %d\n", #BAR , BAR)
SHOW(3+5); // prints: 3+5 is 8
【讨论】:
是Stringizing Operator,它将宏参数转换为字符串字面量。
所以在你的例子中:
my_setopt(1, 2, 3)
将扩展为:
_my_setopt(1, 0, config, "2", 2, 3)
【讨论】: