将预处理器变量传递到nmake构建环境 [英] Passing preprocessor variable to nmake build environment
问题描述
我在使用 nmake
在Win7 x64构建环境中构建驱动程序时遇到问题。我定义一个预处理程序变量,并通过命令行使用 -
I am having issues with building driver using nmake
on Win7 x64 build environment. I am defining a preprocessor variable and passing it over the command line using -
build /nmake "USER_C_FLAGS=/DMyVersion=3"
而构建日志是 -
...
/DMyVersion=3
/typedil-
/wd4603
/wd4627
....
所以,我清楚地看到这个变量是编译器选项的一部分。现在在标题fie,我做
So, I clearly see the variable as part of the compiler options. Now in a header fie, I do
#define otherVersion 10
#ifdef MyVersion
#undef otherVersion
#define otherVersion MyVersion
#endif
#define FileVersion otherVersion
问题是 FileVersion
总是 10 ,不管 MyVersion
定义传递并存在于环境中。要测试,发生了什么,我做了 -
The problem is FileVersion
is always being 10 irrespective of the MyVersion
define passed and exist in the environment. To test, what is going on, I did -
#ifdef MyVersion
#error MyVersion is present in the environment.
#endif
我看到正在打印的语句。但为什么 otherVersion
总是 10 ,尽管环境中存在预处理器指令?为什么它不是通过命令行选项传递的值 3 ?
I see the statement being printed. But why is otherVersion
is always 10 despite the preprocessor directive is present in the environment ? Why it is not taking the value 3 passed via command line options?
推荐答案
肯定,如果这适用于你,但有些人尝试使用msbuild实现完全相同。他们不得不调整项目文件来管理他们的定义进入构建过程。请查看 MSBuild.exe不接受/ p:DefineConstants或/ p:PreprocessorDefinitions
I'm not sure, if this works for you, but some people did try to achieve quite the same using msbuild. They had to adapt the project-file to pipe their definitions "into" the build-process. Have a look at MSBuild.exe not accepting either /p:DefineConstants nor /p:PreprocessorDefinitions
这篇关于将预处理器变量传递到nmake构建环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!