This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Please help me passing a path to preprocessor
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: jp dot guillemin at free dot fr, gcc-help at gcc dot gnu dot org
- Date: Tue, 25 Nov 2003 08:47:41 -0600
- Subject: Re: Please help me passing a path to preprocessor
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