Please help me passing a path to preprocessor
Eljay Love-Jensen
eljay@adobe.com
Tue Nov 25 14:47:00 GMT 2003
Hi jp,
If you are using MYPATH as a string in your source code, you may want to put double-quotes around it in the define in the makefile.
-DMYPATH='"/usr/local/thepath"'
Note that the single-quotes are chomped by the shell that the make spawns to launch the compiler.
Another solution is to string-ize the MYPATH macro variable in your code via:
#define STR_2(x) #x
#define STR(x) STR_2(x)
STR(MYPATH)
The helper macro function STR_2 is necessary so the STR x parm gets expanded. Otherwise you'd end up with "MYPATH" instead of the expansion of MYPATH into /usr/local/thepath that you are hoping for, which STR_2 then stringifies.
You may want to do this instead for STR_2...
#define STR_2(x) L ## #x
...if you need to work with wchar_t strings instead.
HTH,
--Eljay
More information about the Gcc-help
mailing list