[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Feb 4, 2008 5:39 PM, Anthony Williams <anthony@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote: > g++ '-DMY_LOCATION="/usr/local/hardcodedpath"' file.cpp > yea tried this, even with escaping quotes the preprocessor lost them. > A second option is to do the define on the command line without the > quotes, and use a macro to add the quotes: > > g++ -DMY_LOCATION=/usr/local/hardcodedpath file.cpp > > where file.cpp contains: > > #define STRINGIZE2(x) #x > #define STRINGIZE(x) STRINGIZE2(x) Tried this too but not the double macro! > The nesting of the function macros is required to ensure that the > right text gets converted to a string. This doesn't work if > MY_LOCATION can contain commas. Ah this is what i missed! > > A third option is to write it to a header file: I needed to avoid adding files, i just wanted to patch/set a variable. > > Hope that helps. > Yea thanks, (and Neil and Steve too for repling), Currently I have sed doing the dirty work of patching the file, as i am using cmake i can execute abatary applications such as sed only on linux builds (and not mac or windows). But i may switch back to the double macro approach. Regards Robin -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html