0

该宏#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 *

4

0 回答 0