Passing a preprocessor variable to the nmake build environment

I'm having problems with the built-in driver using nmake in the Win7 x64 build environment. I define a preprocessor variable and pass it on the command line with -

 build /nmake "USER_C_FLAGS=/DMyVersion=3" 

And build log -

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

So, I clearly see the variable as part of the compiler options. Now in the heading fie i do

 #define otherVersion 10 #ifdef MyVersion #undef otherVersion #define otherVersion MyVersion #endif #define FileVersion otherVersion 

Problem FileVersion always 10 , regardless of the MyVersion transferred and existing in the environment. To check what happens, I did -

 #ifdef MyVersion #error MyVersion is present in the environment. #endif 

I see a typed expression. But why is otherVersion always 10 , even though the preprocessor directive is present in the environment? Why does it not take the value 3 passed through the command line options?

+4
source share
1 answer

I'm not sure if this will work for you, but some people have tried to achieve the same as using msbuild. They had to adapt the project file to pass their definitions β€œinto” the build process. See MSBuild.exe not accepting / p: DefineConstants nor / p: PreprocessorDefinitions

+1
source

All Articles