2016-11-07 15 views
0

我試圖用coan,產生一個乾淨版本的代碼庫,但它creashes上的第一個定義的第一源代碼精細,使用:科恩給出了「擴展到表達式中沒有」與定義的符號

coan source -DNON_SMS --filter c,h --recurse --replace test -V 

我得到:

coan: progress 0x00101: Processing file (1) 
"D:\Documents\Downloads\test\cli.c" 
coan: D:\Documents\Downloads\test\cli.c: line 53: error 0x00816: "NON_SMS" expands to nothing within expression, in "#if (NON_SMS) /* Non-SMS compile */" 
coan: progress 0x02101: Completed with errors, exit code 0x04 
coan: info 0x02201: 1 out of 41 input files were reached; 40 files were not reached 
coan: info 0x02202: 0 out of 1 files reached were valid; 1 were abandoned due to parse errors 

但代碼上正常工作MSVS及本聲明其實很簡單:

#if  (NON_SMS)     /* Non-SMS compile */ 

#include <stdlib.h>     /* Standard library definitions */ 
#include <string.h>     /* String related definitions  */ 

#else  

這是在Windows 7 x64上。

+1

這是C還是C++?語言之間有區別。例如,C++有'std :: string',而C沒有。在C中,我可以有一個名爲「class」的變量。相應地調整你的標籤。 –

+0

@ThomasMatthews這是既適用於C和C++作爲coan過程都具有相同的接口。 – canesin

+0

嘗試使用'-DNON_SMS = 1'或'-DNON_SMS = 0'。代碼正在檢查值,而不僅僅是它是否被定義。 – Barmar

回答

1

科恩預計,當代碼是這樣

#if (MACRO) 

MACRO將有一個價值 - 如果你只是想測試宏是否被定義,你會寫

#ifdef MACRO 

所以你需要給NON_SMS一個值,例如

coan source -DNON_SMS=1 --filter c,h --recurse --replace test -V 
+0

在gcc和其他常見編譯器中,'-DNON_SMS'實際上表示爲'-DNON_SMS = 1'。我不知道任何關於「coan」的內容,但是如果它給「-D」賦予微妙不同的含義,那麼這對用戶來說有點混亂。 –

+0

@ M.M好的一點,它似乎被視爲「-DNON_SMS =' – Barmar