Visual studio code `语句中间的ifdef`关键字在vscode中不突出显示 在语句中间的 IFDEF关键字在 VSCODES/COD>中没有突出显示粉红色,而在开始时那些关键字被高亮显示。为什么会发生这种情况 class TestClass { int m_x; #ifdef FLAG // This ifdef keyword is highlighted int m_variable_used_when_flag_enabled; #endif TestClass(int x) : m_x(x) #ifdef FLAG // This ifdef keyword is NOT highlighted ,m_variable_used_when_flag_enabled() #endif { } };

Visual studio code `语句中间的ifdef`关键字在vscode中不突出显示 在语句中间的 IFDEF关键字在 VSCODES/COD>中没有突出显示粉红色,而在开始时那些关键字被高亮显示。为什么会发生这种情况 class TestClass { int m_x; #ifdef FLAG // This ifdef keyword is highlighted int m_variable_used_when_flag_enabled; #endif TestClass(int x) : m_x(x) #ifdef FLAG // This ifdef keyword is NOT highlighted ,m_variable_used_when_flag_enabled() #endif { } };,visual-studio-code,vscode-settings,Visual Studio Code,Vscode Settings,在Xcode和Sublime文本上看起来不错。因此,这是一个编辑器的限制,您可能会在VSCode的GitHub repo上提交一个bug 另外,请注意逗号应该在条件中,而不是在条件外。它会导致编译错误 class TestClass { int m_x; #ifdef FLAG // This ifdef keyword is highlighted int m_variable_used_when_flag_enabled; #endif TestClass(int x)

在Xcode和Sublime文本上看起来不错。因此,这是一个编辑器的限制,您可能会在VSCode的GitHub repo上提交一个bug

另外,请注意逗号应该在条件中,而不是在条件外。它会导致编译错误

class TestClass {
  int m_x;
#ifdef FLAG  // This ifdef keyword is highlighted
  int m_variable_used_when_flag_enabled;
#endif
  TestClass(int x)
      : m_x(x)
#ifdef FLAG  // This ifdef keyword is NOT highlighted
        ,
        m_variable_used_when_flag_enabled()
#endif
  {
  }
};


是的,在我制作一个较小的可复制问题时,错误位置的逗号是一个拼写错误。他们有不同的TextMate范围,请参见问题,它不希望函数定义标题中出现#ifdef,这是一个错误,对吗?对不起,我不知道TeTePoT范围。我没有看过C++的TeMax文件,但是它没有给相同的构造相同的范围,所以它是一个bug。