4
我在Win7 x64构建环境中使用nmake
构建驱动程序时遇到问题。我定义预处理程序变量,并通过它使用命令行过 -将预处理器变量传递给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
总是被不论MyVersion
的定义传递,并在环境中存在。要测试,发生了什么,我做了 -
#ifdef MyVersion
#error MyVersion is present in the environment.
#endif
我看到正在打印的声明。但为什么otherVersion
始终是尽管预处理器指令存在于环境中?为什么它没有通过命令行选项传递值?