Hello,
I was trying to use #define directives to make a base directory for all my include files. So the idea was:
Compile the program with a flag -D__BASE__=/some/path/to/base/ and then add this before the filename in the #include.
So basically:
#include __BASE__ "Foo.h"
This does not work (of course), but I searched the internet and found some information about directives and I came up with this:
#define CONCAT(a, b) a b
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define ROOT TOSTRING(__BASE__)
#include CONCAT(ROOT, "Foo.h")
But this does not work either. I think the problem lies in the fact that I do not precisely know how this is processed (although it looks very simple), anyway there are 'tokens' and 'strings' and it just seems I cannot concat two strings.
For example I get things like
"/some/path/" "Foo.h"
or sometimes I even get /some/path/Foo.h, but when using it on the #include it says: /some/path/: No such file or directory, in other words, it only took the first part. So I guess the preprocessor just replaces everything and does not really DO anything.
Anyway, any help would be appreciated. Thank you.
Mark
try #include "__BASE__/./foo.h"
or try #include "__BASE__##foo.h"
You may have better luck passing in the include directory with -I