splint: ask not to check system headers - c

Is there a way to stop splint from analyzing system headers included, POSIX, libc etc.? I run with -warnposix -preproc:
% splint -warnposix -preproc my.c
/usr/include/unistd.h:220:8: Parse Error: Non-function declaration:
__BEGIN_DECLS : int. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.
UPDATE:
% splint +posixlib +unixlib -I/path/to/myheaders -I/usr/include/x86_64-linux-gnu my.c
/usr/include/asm-generic/int-ll64.h:19:24: Parse Error:
Suspect missing struct or union keyword: __signed__ :
int. (For help on parse errors, see splint -help parseerrors.)
After reading splint FAQ14 I tried to eliminate nonstandard keyword:
% splint +posixlib +unixlib -D__signed__= -I/path/to/myheaders -I/usr/include/x86_64-linux-gnu my.c
/usr/include/x86_64-linux-gnu/sys/syslog.h:200:66: Parse Error:
Inconsistent function parameter syntax: __gnuc_va_list :
<any>. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
Declaring __gnuc_va_list as nonstandard keyword doesn't help in this particular case. I feel that splint is a powerful tool, but it requires to annotate almost every code it parses. Am I wrong?

Related

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.
You should pass -Dint32=int.
The splint FAQ states this:
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.

Getting an error for the features.h header, even though I haven't touched it?

I am running Linux Mint. When I try to compile a program in C using gpp from command line, I get this output, and my program does not compile.
$ gpp snake.cpp -o snake
features.h:384: warning: Extra argument to #endif ignored
features.h:396: error: #define/#defeval requires an identifier or a single macro call
I'm not sure why I would ever be getting an error for a standard library that I haven't even touched.

How to use splint under linux with mingw

I run debian linux actual stable with splint and mingw installed.
I want to check my c code (which I need to compile with mingw, sorry) by splint. Simply adding the mingw-includes is not enough to run. I tried with defining GNU and i686 - but I'm sure more is needed. What further do I have to define or include?
I tried the idea from loan resulting in a problem with __builtin_va_list.
Splint 3.1.2 --- 20 Feb 2009
/usr/i686-w64-mingw32/include/vadefs.h:24:43: Parse Error:
Suspect missing struct or union keyword: __builtin_va_list :
int. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
The funny thing is, that I can not find any definition for not - even with a recursive grep on the include folders. Am I searching wrong?
By defining it the way -D__builtin_va_list=va_list (from benjarobin) I ran into the error
Splint 3.1.2 --- 20 Feb 2009
/home/ebelingb/.splintrc:229:1: Setting -stats redundant with current value
/home/ebelingb/.splintrc:229:1: Setting -showsummary redundant with current
value
/usr/i686-w64-mingw32/include/winnt.h:2390:15:
Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
which could not be recovered even by +trytorecover.
The lines from winnt.h (and neighbouring) reads
2388 typedef struct _EXCEPTION_POINTERS {
2389 PEXCEPTION_RECORD ExceptionRecord;
2390 PCONTEXT ContextRecord;
2391 } EXCEPTION_POINTERS,*PEXCEPTION_POINTERS;
Strange, isn't it?
Okay as this thread gets no further answers, I'll give some motivation by this minimal not working example:
Given a file test.c
#include <windows.h>
#include <stdio.h>
#include <time.h>
#define LOGFILEFORMAT "C:\\CBM\\log\\%Y%m%d.log"
#define LOGTIMESTAMPFORMAT "%Y-%m-%d %H:%M:%S"
int main() /*int argc,char **argv*/{
Sleep(1234);
return (0);
}
and my .splintrc
-I/usr/lib/gcc/i686-w64-mingw32/4.6/include
-I/usr/lib/gcc/i686-w64-mingw32/4.6/include-fixed
-I/usr/i686-w64-mingw32/include
the easy command splint test.c fails:
Splint 3.1.2 --- 20 Feb 2009
/usr/i686-w64-mingw32/include/_mingw.h:480:29: Parse Error:
Suspect missing struct or union keyword: __int64 :
long int. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
Again I do not know, how to setup. The includes above result from a preprocesing call of the compiler i686-w64-mingw32-gcc, which runs fine on test.c.
You can get a good list of preprocessor defines using a blank C source file and running it through GCC/MinGW with your desired custom arguments:
gcc -E -P -v -dD [optional arguments] blank.c
Be sure to use the proper compiler for your target. You can redirect the output to a file and pass whatever defines you may need from there to splint.

Error compiling gold in binutils

I am trying to compile the project KernelGen (http://hpcforge.org/plugins/mediawiki/wiki/kernelgen/index.php/Compiling) for some research project I am doing , the build script is using rpmbuild and it looks like it has a dependency on gold from binutils. Build keeps failing when trying to compile gold with the following error:
/bin/sh ./../ylwrap yyscript.y y.tab.c yyscript.c y.tab.h yyscript.h y.output yyscript.output -- byacc -d
byacc: e - line 42 of "/home/xxx/rpmbuild/BUILD/binutils-2.23.2/gold/yyscript.y", syntax error
%pure-parser
^
The file yyscript.c looks like this:
/* We need to use a pure parser because we might be multi-threaded.
We pass some arguments through the parser to the lexer. */
%pure-parser
%parse-param {void* closure}
%lex-param {void* closure}
/* Since we require bison anyhow, we take advantage of it. */
%error-verbose
/* The values associated with tokens. */
It looks like it is some kind of grammar file that fails to parse. Things is this file is from the binutils package itself and I can't find a reason why it is failing to parse.
Any ideas ?
Your version of byacc doesn't properly support %pure-parser, which I believe was originally a bison extension. Use bison instead.

zlib on z/OS USS

Im trying to compile z/lib on z/OS USS(thats right a mainframe). ive got gmake and the c89 compiler (which im assuming is c89 standards compliant) and USS is supposed to be POSIX compliant.
But zlib seems to be tripping up on
struct internal_state FAR *state; /* not visible by applications */
with the following error(s)
c89 -O3 -DUSE_MMAP -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_SOURCE -c -o example.o example.c
ERROR CCN3277 ./zlib.h:92 Syntax error: possible missing ';' or ','?
ERROR CCN3007 ./zlib.h:92 "struct internal_state" is undefined.
ERROR CCN3166 ./zlib.h:103 Definition of function FAR requires parentheses.
ERROR CCN3276 ./zlib.h:103 Syntax error: possible missing '{'?
ERROR CCN3273 ./zlib.h:124 Missing type in declaration of gz_header.
ERROR CCN3166 ./zlib.h:126 Definition of function gz_header requires parentheses.
ERROR CCN3276 ./zlib.h:126 Syntax error: possible missing '{'?
WARNING CCN3137 ./zlib.h:1346 Declaration must declare at least one declarator, tag, or the members of an enumeration.
ERROR CCN3275 ./zlib.h:1350 Unexpected text z encountered.
ERROR CCN3282 ./zlib.h:1350 The type of the parameters must be specified in a prototype.
ERROR CCN3275 ./example.c:95 Unexpected text file encountered.
ERROR CCN3045 ./example.c:95 Undeclared identifier gzFile.
ERROR CCN3046 ./example.c:96 Syntax error.
ERROR CCN3045 ./example.c:98 Undeclared identifier file.
ERROR CCN3019 ./example.c:523 Expecting an array or a pointer to object type.
ERROR CCN3280 ./example.c:527 Function argument assignment between types "const char*" and "int" is not allowed.
CCN0793(I) Compilation failed for file ./example.c. Object file not created.
FSUM3065 The COMPILE step ended with return code 12.
FSUM3017 Could not compile example.c. Correct the errors and try again.
gmake: *** [example.o] Error 3
when i progressively take out the FAR * (i think its a far pointer but im really not that sure) the errors go away. But as this is a library, im not sure what other artifacts are going to be produced by removing this.
has anybody got any ideas?
any old mainframe heads out there?
it turns out there is a previous version of zlib that compiles on USS, version 1.1.4 or close to that. Its a back level, but i presume this works because it is before the implementation of the FAR pointer in the latest code. So atm i think ive got it to work.
thanks for all your help.
Regards
Mark.
FAR is not a C89 keyword, it is a Microsoft/Intelism and is probably #defined somewhere. If not, you need to define it as nothing:
#define FAR
However, this will probably only fix one of many problems. I would guess that the library uses some form of conditional compilation to handle things like FAR pointers - you need to read the docs to find which configuration is most suitabkle for your platform.
I'd use xlc instead of c89 since xlc is your system default compiler but you'll still probably have issues. I'd subscribe to the MVS-OE email list, the people on it are quite helpful. The link to info about the list appears to be down now so send email to
LISTSERV#VM.MARIST.EDU
with the message: INFO MVS-OE
FWIW, IBM provides a prebuilt version of zlib that includes support for the compression hardware (so-called zEDC) available on recent-vintage mainframes. See zlib for zEnterprise Data Compression

Resources