Hi all,
Is it possible to define a preprocessor constant using another constant and a string in the declaration, like this:

#define MAIN_PATH = "C:\\My Documents\\"
#define SUB_DIR = MAIN_PATH + "MyFolder\\"

I'm using VC++ 2010 Express...


What I mean is that I know it's not possible to do it the way I coded it because the compiler is defining SUB_DIR to the value of MY_PATH and it's completely ignoring the rest of the line, but is it possible to concatenate 2 preprocessor constants...?
If not, is it possible to define an include directory 'in-code', not from a project's settings..?

Of course like this

#define ROOT "C:\\SomeRoot\\"
#define SUB_DIR ROOT "SubDir\\"

A rarely use feature of C++ (and C) is the the compiler automatically contatinates contiguous strings.

A better question is should you given this is C++ or should you just use constant objects

const std::string root = "C:\\SomeRoot\\";
const std::string subdir = root + "SubDir\\";

Thanks, just what I needed!

ps: I wasn't going to use normal string constants as I wanted to use them in an '#include' statement...

You shouldn't be putting paths into #include statements on the whole, it makes it very hard to take the code to another computer unless it has exactly the same hard-drive and directory set-up.

You can pass the directory(ies) to search for include files into the compile normally using the -I switch or set it in your IDE in the project properties.