#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));
Run Code Online (Sandbox Code Playgroud)
这个宏在VS编译器中工作正常,但不能在GCC编译器上编译:
错误:错误:粘贴"/"和"includefile"不提供有效的预处理令牌
对于某些包含文件,它会给出错误:
错误:粘贴"includefile"和"." 不提供有效的预处理令牌