문제

I'm trying to run splint on a C source that includes complex.h from the standard C library to support complex arithmetic.

Unfortunately, splint fails with the following error.

Splint 3.1.2 --- 03 May 2009

/usr/include/bits/cmathcalls.h:54:31: Parse Error: Non-function declaration: _Complex : extern double. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue.

Googling for the problem resulted in only this message on the split-discuss mailing list (which remains unanswered).

Any ideas?

Update

Here is a very simple example of a failing source:

#include <complex.h>

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

Attempts to redefine the unsupported _Complex C99 Keyword leads to an error with the imaginary part of the complex number (which isn't surprising I suppose).

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.
도움이 되었습니까?

해결책 3

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

다른 팁

I'm not a splint user, so take the following with a grain of salt...

The _Complex keyword was added with C99, and the splint FAQ has this to say about C99 (http://www.splint.org/faq.html#quest15):

However, Splint doesn't yet support all C99 extensions so there are some legitimate C programs that will need to be modified.

I'd guess that _Complex is covered by that caveat.

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top