Search code examples
c++visual-c++command-linec-preprocessor

How can I make a string preprocessor definition from command-line in VC 2005 (C++)?


The documentation tells me that /D command-line switch can be used to do this, like so:

CL /DDEBUG TEST.C

This would define a DEBUG symbol, and

CL /DDEBUG=2 TEST.C

would give it the value 2.

But what do I do if I would like to get the equivalent of a string define, such as the following?

#define DEBUG "abc"

Solution

  • Due to the way command line is parsed in Windows, you'll have to escape the quotes.

    CL /DDEBUG=\"abc\" TEST.C