D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] c++ preprocessor passing strings

 

How can i set "/usr/local/hardcodedpath" at compile time?
Is there an easy C++ way of using preprocessors, i've tried passing
values over -DMY_LOCATION and using

data_location = MY_LOCATION

but as the string is unquoted this fails. It does not seem possible to
pass quoted values via the preprocessor.

You're on the right track with using -D

All you have to do is shell-escape the quotation marks so that it stays a string once the preprocessor gets its hands on it. So pass:

-DMYLOCATION='"/usr/local/hardcodedpath"'

The outer single quotes will protect the inner double quotes.
-- 
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