VS2017项目配置预处理器定义在C ++项目中不起作用?

时间:2019-04-25 23:24:50

标签: c++ visual-studio-2017 preprocessor conditional-compilation

我在VS2017项目属性(Windows 8.1上的VS2017版本15.9.6)中设置了一个称为PRIVATE_CODE的预处理程序定义:

  • 右键单击解决方案
  • 配置属性
  • C / C ++
  • 预处理器
  • 预处理程序定义(字段)

但是,当我查看任何要定义的文件中的代码时,该代码未使用。我之所以知道是因为在深色主题的IDE中,IFDEF部分中的代码变暗了,而ELSE部分中的代码是正常亮度。

绝对可以肯定的是,我在每一节中都放了一段糟糕的代码,以查看哪一部分触发了编译器错误:

#ifdef PRIVATE_CODE
    // This should trigger a compiler error.
    adadfadsf;
#else
   // Instead, I get a compiler error here, indicating that the compiler
   //  is not paying attention to the preprocessor definitions I set.
   asdfadfff;
#endf

还有其他人有这个问题,并且知道为什么会这样吗?

0 个答案:

没有答案
相关问题