Debian splintrc预处理器指令-D中的空白
我想在debian稳定环境中的一些源代码上运行Debian splintrc预处理器指令-D中的空白,debian,whitespace,preprocessor-directive,splint,secure-coding,Debian,Whitespace,Preprocessor Directive,Splint,Secure Coding,我想在debian稳定环境中的一些源代码上运行splint。 我需要给出预处理器指令-DUINT16\u T='unsigned short',正如我经常需要的那样。我想把它放在我的.splintrc文件中。 当从命令行运行时,比如splint-DUINT16\u T='unsigned short'mysource.c它工作得很好。如果将此行移动到我的.splintrc文件中 -DUINT16_T='unsigned short' -I/usr/local/include/ splint调用
splint
。我需要给出预处理器指令
-DUINT16\u T='unsigned short'
,正如我经常需要的那样。我想把它放在我的.splintrc
文件中。当从命令行运行时,比如
splint-DUINT16\u T='unsigned short'mysource.c
它工作得很好。如果将此行移动到我的.splintrc
文件中
-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)
有人有解决办法吗?(请不要化名)
为了进一步讨论,我将提供一个mnwe(最小不工作示例)hello.c
,这可能会有帮助:
#include <stdio.h>
int main (void)
{
UINT16_T returnvalue=0;
printf ("Hello, world!\n");
return returnvalue;
}
但是,我又如何将这个定义包含到我的.splintrc
?新答案中呢--
你所要求的只是在夹板中没有实现
如果查看rcfiles.c第124行中的splint 3.1.2rcfiles\u loadFile函数
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 /*@innerbreak@*/ break;
154 }
155 }
156
157 s++;
158 incColumn ();
159 }
您可以看到,第125行中的注释是您所问问题的待办事项
我把电话线改成151
151 if (c == '\t' || c == '\n')
编译、运行,然后您的最小不工作示例(在.splintrc中没有引号)将顺利通过测试
然而,这种修改有点粗糙,因为一些夹板单元测试失败。使用双引号而不是单引号
-DUINT16_T="unsigned short"
我需要同样的东西,除了标志:“-Dbit=unsigned char”我尝试过了-并且您的文件运行良好-但是尝试#include int main(void){UINT16_T returnvalue=0;printf(“Hello,world!\n”);returnvalue;}然后您将只在运行中看到,因为没有使用define。如此悲伤。更多提示/想法?目前我无法尝试,但查看评论后,我认为双引号也不起作用。该评论中的引号不适用于
.splintrc
。正如您可以从源代码中看到的,字符串使用'\'
char引用。
-DUINT16_T="unsigned short"