1

My problem:
I have created a C project in Visual Studio 2010 and defined a conditional compilation constant named QWERTY. My C source code executes #ifdef QWERTY in order to see if it's defined or not. When I add /DQWERTY into the command line additional options of my C project in the IDE, then the constant is correctly detected after compilation, just as expected.

So, my questions is: how can I define that constant from the command line using MSBuild?

Just for clarity reasons, I'm running this command:

MSBuild myproj.sln

Please don't propose to use the switch /p:DefineConstants; I've created a C project, not a C# project, and that switch is useless for C/C++ projects.

As you've probably already understood, I'm feeling more and more desperate about this trivial problem. Please enlighten me and show me that there is a simple solution around the corner that I've missed of pure stupidity.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Inferato
  • 11
  • 1
  • possible duplicate of [MSBuild.exe not accepting either /p:DefineConstants nor /p:PreprocessorDefinitions](http://stackoverflow.com/questions/2016697/msbuild-exe-not-accepting-either-pdefineconstants-nor-ppreprocessordefinition) – Oliver Charlesworth Feb 12 '11 at 17:48
  • 1
    have you tried `set CL=/DQWERTY` – smerlin Feb 12 '11 at 18:04
  • Ah, very brutal solution, but yet effective. Nice. It works. I would have preferred some injection support through MSBuild, but your solution work as well. Most important, it solves my problem. Thank you smerlin. – Inferato Feb 13 '11 at 18:11

0 Answers0