【发布时间】:2012-06-11 22:48:32
【问题描述】:
我在 Win7 x64 构建环境中使用 nmake 构建驱动程序时遇到问题。我正在定义一个预处理器变量并使用 -
build /nmake "USER_C_FLAGS=/DMyVersion=3"
而构建日志是 -
...
/DMyVersion=3
/typedil-
/wd4603
/wd4627
....
所以,我清楚地将变量视为编译器选项的一部分。现在在标题文件中,我这样做了
#define otherVersion 10
#ifdef MyVersion
#undef otherVersion
#define otherVersion MyVersion
#endif
#define FileVersion otherVersion
问题是 FileVersion 始终为 10 而不管 MyVersion 定义是否已通过并存在于环境中。为了测试,发生了什么,我做了 -
#ifdef MyVersion
#error MyVersion is present in the environment.
#endif
我看到正在打印的语句。但是为什么 otherVersion 总是 10 尽管环境中存在预处理器指令?为什么它不采用通过命令行选项传递的值 3?
【问题讨论】:
标签: c++ c-preprocessor visual-studio-2005 nmake wdk