This is driving me nuts. I have a macro defined on the command line with the -D option
-DFOO="foobarbaz"
And then I want to do something like this
string s = "FOO" ;
To get
string s = "foobarbaz" ;
Because apparently the quotes from the command line are stripped away, even when I try to escape them with \. I’ve tried everything I could think with stringification and additional macros and it just won’t work. Either I get an error from the preprocessor about misplaced # signs, or I end up with
string s = foobarbaz ;
which obviously won’t compile.
Use this on the command line:
For example test.cpp is:
Compiling and running gives:
EDIT This is how you would do it from a Makefile: