How do I make a line preprocessor definition from the command line in VC 2005 (C ++)?
the documentation tells me that the D command line switch can be used for this, e.g .:
CL /DDEBUG TEST.C
will define a DEBUG character and
CL /DDEBUG=2 TEST.C
will give it the value 2. But what if I would like to get the equivalent of a string definition, like
#define DEBUG "abc"
?
+2
source to share
5 answers
I don't have a VC to test this for you, however in principle the following should work:
CL /DSTRINGIFY(X)=#X /DDEBUG=STRINGIFY(abc) TEST.C
Update:
As Coober-Aubert stressed, VC doesn't seem to be doing the right thing here. Testing with a simple example generates:
const char * s = STRINGIFY(abc);
It can work with other compilers, for example the following g ++ command line works:
g++ -D'STRINGIFY(X)=#X' -D'DEBUG=STRINGIFY(abc)' t.cc -E
# 1 "t.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cc"
const char * s = "abc";
-1
source to share