2014-02-24 40 views
1

我正在使用嵌入式系统XC8 C编译器(用于PIC微处理器)。以下是允许的:非标准函数返回类型:修复Splint解析错误

bit foo(){ 
    //... 
} 

但作为非标准C,夹板静态分析器提供了以下错误:

Parse Error: Non-function declaration: bit : "--------------------------------------" int.

和文件/误差线是函数原型中相应的.h文件。

我该如何解决这个问题,以便Splint可以分析文件的其余部分?我想可能有两个方面:

  1. 我认为我记得看到它可以通过通过CLI告诉它来代替一个给定的非标型为标准型,以夹板固定(如位无符号标志字符),但我似乎无法找到它现在!

  2. 此外,也许有另一种方法来编写满足ANSI-C要求的c代码,同时还允许XC8将返回类型解释为bit

进展:

我发现了一个论坛下面,但我无法找到如何在manual使用-D标志信息:

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.

回答

2

如果分析程序没有选择进行替换,您当然可以使用预处理器进行替换。

有类似:

#if defined RUNNING_SPLINT 
#define bit unsigned char 
#endif 

在如您确定的标题包含在任何地方,enter code here并确保您在Splint看到代码时确定预处理器符号RUNNING_SPLINT。它有一个-D标志。

0

这是在常见问题解答:

http://www.splint.org/faq.html

引述它:

16.I develop code on an embedded system with a compiler that uses nonstandard key words and data types. I would like to run Splint on my code but these nonstandard keywords cause parse errors. What should I do?

You can often use -D to solve this problem.

If you just want to ignore a keyword, you can add -Dnonstandardkeyword= to make the preprocessor eliminate the keyword, where nonstandardkeyword is the name of the keyword. Similarly, you can use -Dspecialtype=int to make a custom type parse as an int.