1

我正在尝试splint在包含complex.h标准 C 库的 C 源代码上运行以支持复杂的算术。

不幸的是,splint失败并出现以下错误。

夹板 3.1.2 --- 2009 年 5 月 3 日

/usr/include/bits/cmathcalls.h:54:31:解析错误:非函数声明:_Complex:extern double。(有关解析错误的帮助,请参阅 splint -help parseerrors。) *** 无法继续。

谷歌搜索该问题仅在拆分讨论邮件列表中显示此消息(仍未得到答复)。

有任何想法吗?

更新

这是一个非常简单的失败源示例:

#include <complex.h>

int main() {
  complex x = 2 + 8i;
  x = x + 1;
}

尝试重新定义不受支持的_ComplexC99 关键字会导致复数的虚部出现错误(我想这并不奇怪)。

lsc@deepthought:~$ splint-D_Complex=double temp.c  
Splint 3.1.2 --- 03 May 2009

 temp.c:4:20: Parse Error. (For help on
 parse errors, see splint -help
                parseerrors.)
*** Cannot continue.
4

3 回答 3

3

我不是夹板使用者,所以请注意以下内容...

关键字是用 C99 添加的_Complex,夹板常见问题解答对 C99 有这样的说法(http://www.splint.org/faq.html#quest15):

但是,Splint 还不支持所有 C99 扩展,因此有一些合法的 C 程序需要修改。

我猜这_Complex已经被那个警告所涵盖了。

You might be able to work around splint's apparent lack of support for _Complex using a technique described in the FAQ (http://www.splint.org/faq.html#quest14), but I'd be surprised if this got you very far with helping splint deal with C99 code using _Complex:

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.

于 2010-06-29T20:01:17.507 回答
2

I was struggling to get splint to ignore headers and not finding suitable answers anywhere online. I finally used splint's built-in help, and discovered this:

#ifndef S_SPLINT_S

#endif

If you put this pair around code you want splint to ignore, it will ignore it! None of the other things work for system header files, at least that I've found.

于 2013-09-17T09:37:43.357 回答
0

I eventually solved this by temporarily overriding complex.h with a dummy one when calling splint.

[lsc@home]$ ls /opt/qa_tools/utils/splint_includes/
complex.h

[lsc@home]$ splint -I/opt/qa_tools/utils/splint_includes test.c
Splint 3.1.1 --- 15 Jun 2004

Finished checking --- no warnings

The dummy complex.h file suppresses the relevant keywords and replaces constants/functions with dummy ones. These keywords/constants/functions were gleaned from the specs

A copy of this file is available here: https://gist.github.com/1316366

于 2011-10-26T13:38:42.077 回答