Re: Please help me passing a path to preprocessor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux