Passing preprocessor variable to nmake build environment

爱⌒轻易说出口 提交于 2019-12-23 14:49:48

问题


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"

And the build log is -

...
/DMyVersion=3
/typedil- 
/wd4603
/wd4627
....

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

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

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?


回答1:


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



来源:https://stackoverflow.com/questions/10988501/passing-preprocessor-variable-to-nmake-build-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!