该宏#define STR16(x) L ## x
在应用于字符串文字时起作用:
STR16("Hello") // fine, this is translated to L"Hello"
但不是变量:
STR16(x) // fails, this is translated to Lx, and the variable Lx doesn't exist
在这个有用库的第 200 行,有一个错误:
Parameter* param = new RangeParameter( STR16(p->GetNameForHost()), ...
将被翻译成
Parameter* param = new RangeParameter( Lp->GetNameForHost(), ...
失败,因为Lp
是一个未声明的标识符。
L
除了将字符串文字添加到字符串变量之外,如何做同样的事情const char *
?