views:

32

answers:

1

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.
+2  A: 

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.

Michael Burr
+1 Thanks Michael. I have tried ignoring and redefining the _Complex keyword by passing -D_Complex=?? to splint, but splint proceeds to choke on the imaginary part of the complex number definition (e.g. complex x = 2 + 8i). Will update question with more info.
lsc