I am trying to pass a string as parameter when compiling to this code:
#include <iostream>
#define MY_STRING #STRING_IN
int main(int argc, char** argv) {
std::cout << MY_STRING;
}
Compiled with the flag
-DSTRING_IN=foo
I get following error
error: stray '#' in program
#define MY_STRING #STRING_IN
^note: in expansion of macro 'MY_STRING'
std::cout << MY_STRING; ^~~~~~~~~[...]
Compiler returned: 1
See also here.
How can I pass a parameter via -D... and then turn that into a string?