How to concatenate macro definition and a string

Can I make something like this work?

1
2
3
4
5
6
// consider that macro PARENT defined when compiling using preprocessor options

string filepath = PARENT + "rest/of/the/path";
// or something like this

open(PARENT + "rest/of/the/path")
It should work if you drop the plus sign and if parent is #defined appropriately with quotation marks.
Thanks. It works.
Er, why are you hardcoding top-level paths?
Because I want it to be decided by configuration script. I have made configuration script to put something like this on the command line when compiling:
 
g++ -DPARENT="/usr/local/share" ...(rest of the options goes here)


Edit: I am getting the location of data files like this, so that my program know where to look for. Since location of data files depends on options passed to ./configure script, it is the only way I could know about my data files (e.g. images, sounds and stuff.)
Last edited on
Topic archived. No new replies allowed.