views:

176

answers:

4

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

  CL /DDEBUG TEST.C

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

  #define DEBUG "abc"

?

+2  A: 

Have you tried

CL /DDEBUG=abc TEST.C

or

CL /DDEBUG="abc" TEST.C
Glen
A: 

I don't have VC to test this for you, however, in principle the following should work:

CL /DSTRINGIFY(X)=#X /DDEBUG=STRINGIFY(abc) TEST.C
Richard Corden
+1  A: 

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

CL /DDEBUG=\"abc\" TEST.C
avakar
A: 

Thanks Glen, the second one could work on the command line, but the coworker I've asked this for eventually used this in the project definition (needing to escape the double-quotes and replace = with #):

/DDEBUG#\"abc\"
MaxVT