csplint

How to resolve a Splint Parse Error for `int32 l[2]`


I have some C code that includes a header for a propriety legacy application. I cannot modify the header. I'm receiving a splint Parse Error for the following code:

#if defined(HAS_LONGLONG)
    /* removed for brevity */
#elif defined(HAS_INT64)
    /* removed for brevity */
#else
  typedef union {
    int32   l[2]; /* This is the line that is causing the parse error in splint */
    double  d;
  } int64;
#endif

Is there any parameter I can pass to splint to get this working?

The platform is 64 bit but the legacy application is 32 bit.

I'm running splint like:

[me@host]$ splint -I/path/to/include -preprox -warnposix

Splint 3.1.1 --- 28 Apr 2003
/path/to/include/some_header.h:7:10:
    Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.

Without -preprox and -warnposix I get a lot of other errors in the legacy header.


Solution

  • You should pass -Dint32=int.

    The splint FAQ states this:

    1. 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.