D&C GLug - Home Page

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

Re: [LUG] c++ preprocessor passing strings

 

On Mon, 2008-02-04 at 14:10 +0000, Robin Cornelius wrote:
> Hi Everyone,
> 
> Can't get my head around something that is probably very very simple
> 
> I have some code like this :-
> 
> std::string data_location
> data_location = "/usr/local/hardcodedpath"
> 
> 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.
> 
> The only thing i can think to do is to run sed at the file first?

Include the quotes in the variable:
(in Makefile.am)

AM_CFLAGS = \
 -I.. -I../.. \
 ${PISOCK_CFLAGS} \
 -DLOCALE_DIR=\""$(datadir)/locale"\" 

(in the source code)
  bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);


-- 


Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/


Attachment: signature.asc
Description: This is a digitally signed message part

-- 
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