#define PATH "yagh/headers/"
#define FILNAME "includefile"
#define CONCAT(a__, b__) CONCAT_DO(a__, b__)
#define CONCAT_DO(a__, b__) a__##b__
#define CONCATTHREE(a__, b__, c__) CONCAT(CONCAT(a__, b__), c__)
#define STRINGIFY(a__) #a__
#include STRINGIFY(CONCATTHREE(PATH ,FILNAME ,.h));
This macro works fine in VS compiler but does not compile on GCC compiler:
Error: error: pasting "/" and "includefile" does not give a valid preprocessing token
and for some include files it gives the error:
Error: pasting "includefile" and "." does not give a valid preprocessing token
GCC is being a bit stricter in enforcing the C standard: see Differences in Macro ## concatenation operator between Visual-C++ and gcc and http://gcc.gnu.org/onlinedocs/gcc-4.3.3/cpp/Concatenation.html#Concatenation.
You might try #include STRINGIFY(PATH FILNAME.h)
(the lack of space between FILNAME
and .h
is important) -- that works for me with gcc 4.6.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With