Is there a way to add extra preprocessor #define in devenv command line?
how do I add preprocessor #define in devenv command line?
10.3k views Asked by Paulius Liekis At
5
There are 5 answers
0
On
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
0
On
I couldn't find a way without modifying solution or project files so I came up with the following:
- Create empty file as part of build e.g.
feature_flag.h - Replace
#if FEATURE_FLAGwith#if !__has_include("feature_flag.h") - Remove
feature_flag.hat the end of the build
It's not using #define but it does use the preprocessor which was what I needed.
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.
Additional answer based on comments:
You should be able to set the CL environment variable with the extra preprocessor define:
Mere information can be found at MSDN