有人可以解释为什么以下不起作用?
int main() // Tried on several recent C++ '03 compilers.
{
#define FOO L
const wchar_t* const foo = FOO"bar"; // Will error out with something like: "identifier 'L' is undefined."
#undef FOO
}
Run Code Online (Sandbox Code Playgroud)
我认为预处理是在比字符串文字操作和一般令牌翻译更早的翻译阶段完成的.
编译器不会或多或少看到这个:
int main()
{
const wchar_t* const foo = L"bar";
}
Run Code Online (Sandbox Code Playgroud)
如果有人能引用标准的解释,那就太好了.