how do I add preprocessor #define in devenv command line?

岁酱吖の 提交于 2020-01-02 01:04:41

问题


Is there a way to add extra preprocessor #define in devenv command line?


回答1:


I am not entirely sure what you mean by vcbuild command line but if you mean the Visual C++ command line compiler then you can add defines by add /Dxxxx, e.g.

cl.exe /DSHAREWARE ....

Additional answer based on comments:

You should be able to set the CL environment variable with the extra preprocessor define:

SET CL=/DSHAREWARE
devenv ....

Mere information can be found at MSDN




回答2:


The #defines are defined in your Visual Studio project file (.dsp or .vcproj file). This is a simple text file. So you could edit the project file from a script, then call devenv.exe.




回答3:


in your project settings, add the following preprocessor definition:

$(MyPreprocessorDefinitions);

then in your *.bat file, use

REM #define MY_DEF

set MyPreprocessorDefinitions=MY_DEF

devenv.exe ...

REM #undefine MY_DEF

set MyPreprocessorDefinitions=




回答4:


In my case, I needed to use devenv for other reasons, (and was running in cygwin, so i had sed).

I set a Compilation symbol in the project's properties SED_REPLACE_THIS and then used sed to set it to something meaningful (ie: DONT_CRASH_AS_MUCH)

sed -i 's/SED_REPLACE_THIS/DONT_CRASH_AS_MUCH/g' project.csproj



来源:https://stackoverflow.com/questions/1783158/how-do-i-add-preprocessor-define-in-devenv-command-line

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