#define并不是简单复制
经过了预编译, 还是有些不一样的.
MSDN中使用#符的例子:
#define stringer( x ) printf( #x "\n " )
int main()
{
stringer( In quotes in the printf function call );
stringer( "In quotes when printed to the screen " );
stringer( "This: \ " prints an escaped double quote " );
return 0;
}// OK
改为下面这样:
int main()
{
printf(#In quotes in the printf function call "\n ");
return 0;
}// ERROE
一直以为#define就是记下它后面的文本串, 没想到还是有些其它处理的.
谁来说说?
[解决办法]
你这个属于宏定义中“#”连接符的运用。
[解决办法]
最好找More Execeptional C++ Item 35. #Definition看一下。
[解决办法]
# 属于特例,
它把宏参数x转化为一个 字符串了 ......