非标准函数返回类型:固定夹板解析错误 [英] Non-standard function return types: Fixing Splint parse error
问题描述
我使用的是嵌入式系统XC8 C编译器(用于PIC微处理器)。以下是允许的:
位富(){
// ...
}
但作为非标C,夹板静态分析仪提供了以下错误:
解析错误:非函数声明:位:
--------------------------------------
INT。
块引用>和错误的文件/行是函数原型在各自的.h文件中。
我怎样才能解决这个如此夹板可以分析文件(S)的休息吗?我觉得可能有两种方式:
我想我记得看到它可以传递通过CLI告诉它来代替一个给定的非标型为标准型,以夹板标志(如位无符号字符),但我似乎无法给发现它在所有吧!
此外,也许有写C code,它满足ANSI-C要求,同时仍然允许XC8国米preT的返回类型为
的另一种方式位
?进展:的
我发现在一个论坛以下,,但我无法找到如何在的手动
要忽略一个关键词,增加-Dnonstandardkeyword =使
preprocessor消除
块引用>和
使用-Dspecialtype = INT做出一个自定义类型解析为int。
块引用>解决方案如果没有选项的分析程序做替换,你当然可以不使用preprocessor它。
有类似:
#如果定义RUNNING_SPLINT
#定义位无符号字符
#万一在如您确保到处包含的头,
在这里输入code
,并确保您定义的pre-处理器符号RUNNING_SPLINT
当夹板看到code。它有一个-D
标志这一点。I'm using the embedded-system XC8 C compiler (for PIC microprocessors). The following is allowed:
bit foo(){ //... }
but being non-standard C, the Splint static analyser gives the following error:
Parse Error: Non-function declaration: bit : "--------------------------------------" int.
And the file/line of the error is the function prototype in the respective .h file.
How can I fix this so Splint can analyse the rest of the file(s)? I think there might be two ways:
I think I remember seeing a flag which can be passed to Splint via CLI which tells it to substitute a given non-standard type to a standard type (e.g. bit to unsigned char) but I can't seem to find it at all now!
Also, perhaps there is an alternative way to write the c code that satisfies ANSI-C requirements while also still allowing XC8 to interpret the return type as
bit
?Progress:
I found the following on a forum, but I can't find information on how to use the -D flag in the manual:
To ignore a keyword, add -Dnonstandardkeyword= to make the preprocessor eliminate it
And
use -Dspecialtype=int to make a custom type parse as an int.
解决方案If there's no option for the analysis program to do the substitution, you can of course do it using the preprocessor.
Have something like:
#if defined RUNNING_SPLINT #define bit unsigned char #endif
in e.g. a header that you make sure is included everywhere,
enter code here
and make sure you define the pre-processor symbolRUNNING_SPLINT
when Splint sees the code. It has a-D
flag for this.这篇关于非标准函数返回类型:固定夹板解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!