小编bla*_*ecl的帖子

C++翻译阶段混乱

有人可以解释为什么以下不起作用?

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)

如果有人能引用标准的解释,那就太好了.

c++ c-preprocessor

4
推荐指数
1
解决办法
367
查看次数

标签 统计

c++ ×1

c-preprocessor ×1