2011-01-12 76 views
6
#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)); 

此宏工作正常VS編譯器,但在GCC編譯器不編譯:預處理宏GCC:粘貼X和X沒有給出一個有效的預處理標記

Error: error: pasting "/" and "includefile" does not give a valid preprocessing token

對於一些包含文件它給錯誤:

Error: pasting "includefile" and "." does not give a valid preprocessing token

+1

使用`##`運算符的連接不能在GCC中使用字符串文字,例如`「foo」`。你究竟想用這個宏做什麼? – thkala 2011-01-12 10:45:24

回答