我在windows上使用MPLAB (3.26)和PIC32 (XC32 v1.40编译器)。我试图使用夹板对某些人的代码进行静态代码分析,作为评审的一部分。我已经对大多数编译器定义和搜索路径进行了排序,但在避免PIC32 std包含文件中的解析错误时,会遇到一些困难。
我用来运行splint的命令是
splint ^
-D"__32MX370F512L__" ^
-D"__PIC32_FEATURE_SET__"=370 ^
-D"__LANGUAGE_C__" ^
+I"C:/Program Files (x86)/Microchip/xc32/v1.40/pic32mx/include/" ^
main.c然后输出
< Location unknown >: Field name reused:
Code cannot be parsed. For help on parse errors, see splint -help
parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of
< Location unknown >: Previous use of
.... approx 100 times then...
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(4,18):
Datatype ptrdiff_t declared with inconsistent type: long int
A function, variable or constant is redefined with a different type. (Use
-incondefs to inhibit warning)
load file standard.lcd: Specification of ptrdiff_t: arbitrary integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(5,27):
Datatype size_t declared with inconsistent type: unsigned long int
load file standard.lcd: Specification of size_t:
arbitrary unsigned integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(6,13):
Datatype wchar_t declared with inconsistent type: int
load file standard.lcd: Specification of wchar_t: arbitrary integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stdarg.h(75,36):
No type before declaration name (implicit int type): __builtin_va_list :
int
A variable declaration has no explicit type. The type is implicitly int.
(Use -imptype to inhibit warning)
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stdarg.h(75,36):
Parse Error: Suspect missing struct or union keyword: __builtin_va_list :
int. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.最后一种导致事情停止。我试过像-跳过-等-头没有运气。它似乎看到了standard.lcd文件和xc32 std文件的问题。
有人能告诉我吗
< Location unknown >: Field name reused:的意思或可能指的是什么?到目前为止,解决头文件问题的唯一方法是定义类型。
-D"__builtin_va_list"=int ^发布于 2016-10-24 16:54:07
我认为您的代码(或您#包含的一些代码)使用的是匿名位字段或/和结构。匿名结构和匿名联合是由GNU扩展为C的版本提供的,它们比C11更早。由于Splint不知道C11 (我只在手册中找到了提到C99的地方,以及谷歌 同意)和只部分支持GNU扩展 (搜索gnu-扩展),所以很难解析它们。
我在为PIC18f46k22编写的一些代码中遇到了类似的问题,尽管我使用的是sdcc而不是XC8。
这个问题与pic18f46k22.h有关,它的类型联合中包含匿名结构(尤其是位字段)。
这个密码..。
typedef union
{
struct
{
unsigned name0 : 1;
unsigned name1 : 1;
unsigned name2 : 1;
unsigned name3 : 1;
unsigned name4 : 1;
unsigned : 1;
unsigned : 1;
unsigned : 1;
};
struct
{
unsigned name : 6;
unsigned : 2;
};
} __NAMEbits_t;...would产生了这些错误..。
< Location unknown >: Field name reused:
Code cannot be parsed. For help on parse errors, see splint -help
parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of...but这段代码不会。
struct indv
{
unsigned name0 : 1;
unsigned name1 : 1;
unsigned name2 : 1;
unsigned name3 : 1;
unsigned name4 : 1;
unsigned : 1;
unsigned : 1;
unsigned : 1;
};
struct all
{
unsigned name : 6;
unsigned : 2;
};
typedef union
{
struct indv individualbits;
struct all allbits;
} __NAMEbits_t;发布于 2020-12-22 20:15:24
我正在使用不同的处理器、编译器和静态分析工具(PRQA / Helix ),但我认为我们在标准头文件的解析问题上也面临着同样的问题。我花了一些时间才弄清楚到底是怎么回事。
首先,我可以说,你的解决办法足够好,显然你不应该太担心它。我使用了一个稍微不同的解决方法,在这里描述:不处理预处理代码的not解析器
-D __builtin_va_list = struct __builtin_va_list {}我想另一种方法是使用存根标准头而不是真正的头。例如,我的工具手册声称工具中应该有这样的头文件,尽管我还没有找到/获得它们。
https://stackoverflow.com/questions/36465544
复制相似问题