6

我想在debian穩定環境中的某些源上運行splint
我需要給予預處理指令-DUINT16_T='unsigned short',因爲我經常需要它。我想將其放入我的.splintrc文件中。
從命令行運行如splint -DUINT16_T='unsigned short' mysource.c它運行良好。如果移動此行到我.splintrc文件.splintrc預處理程序指令中的WhiteSpaces -D

-DUINT16_T='unsigned short' 
-I/usr/local/include/ 

splint調用導致

Cannot list files in .splintrc files: 
           short' (probable missing + or -) 
    A flag is not recognized or used in an incorrect way (Use -badflag to inhibit 
    warning) 

任何人都有一個解決方案? (請不要別名)。

對於furher討論,我會提供一個mnwe(最小不工作的例子)hello.c,這可能有助於:

#include <stdio.h> 

int main (void) 
{ 
    UINT16_T returnvalue=0; 
    printf ("Hello, world!\n"); 
    return returnvalue; 
} 

命令gcc -DUINT16_T='unsigned short' hello.c運行正常 - 也確實splint -DUINT16_T='unsigned short' hello.c當然號稱

Return value type unsigned short int does not match declared type 
       int: returnvalue 

但是,如何將此DEFINE納入我的.splintrc

+1

我需要同樣的事情,除了標誌:「-Dbit =無符號的字符」 – Jodes 2014-02-24 12:58:24

回答

1

- 新回答 -

你在問什麼只是沒有實施夾板。

如果你看一下夾板3.1.2 rcfiles_loadFile功能rcfiles.c線124

124   while ((c = *s) != '\0') 
125    { /* remember to handle spaces and quotes in -D and -U ... */ 
126    if (escaped) 
127     { 
128     escaped = FALSE; 
129     } 
130    else if (quoted) 
131     { 
132     if (c == '\\') 
133      { 
134      escaped = TRUE; 
135      } 
136     else if (c == '\"') 
137      { 
138      quoted = FALSE; 
139      } 
140     else 
141      { 
142      ; 
143      } 
144     } 
145    else if (c == '\"') 
146     { 
147     quoted = TRUE; 
148     } 
149    else 
150     { 
151     if (c == ' ' || c == '\t' || c == '\n') 
152     { 
153      /*@[email protected]*/ break; 
154     } 
155    } 
156 
157    s++; 
158    incColumn(); 
159    } 

你看,在管線125的註釋是你問一個TODO。

我改了行151

151     if (c == '\t' || c == '\n') 

編譯,運行,然後你的最小不工作的例子(沒有引號.splintrc)是通過測試沒有問題。

但是這個修改有點粗糙,因爲一些夾板單元測試失敗了。

+0

嗨Ortomala,傷心這是不是爲我工作。 – 2014-08-05 10:59:00

+0

它應該工作,再試一次。 – 2014-08-05 12:06:19

+0

我試過了 - 你的文件運行良好 - 但是試試#include int main(void) { UINT16_T returnvalue = 0; printf(「Hello,world!\ n」); return returnvalue; }那麼你只會看到在運行中,因爲沒有使用定義。好難過。 Furhter提示/想法? – 2014-08-06 13:56:46

0

使用雙引號而不是單引號。

-DUINT16_T="unsigned short" 
+0

目前我無法嘗試,但看看評論http://stackoverflow.com/questions/15220228/whitespaces-in-splintrc-preprocessor-directive-d/29901100?iemail=1&noredirect=1#comment33322234_15220228我也認爲雙引號不起作用。 – 2015-04-29 11:27:18

+1

該評論中的引號不適用於'.splintrc'。正如你從源代碼中看到的那樣,字符串被''''''char引用'quoted'。 – LennyB 2015-04-30 13:07:56