[splint-discuss] Parse Error on Macro, help
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed Sep 6 02:10:40 EDT 2006
raymond <raymond-xu at 126.com> wrote:
Thanks your advices, but when I try your code, splint doesn't work, it
still has the same parse error,
OK, we now understand the problem completely.
The original code had THREE problems (FOUR if you count () in a macro):
(1) The double semicolon (not legal anywhere)
(2) Struct initialisation by name instead of position (C99)
AND
(3) u_int16_t (uint16_t is in C99 <stdint.h> and <inttypes.h>)
It turns out that Linux defines u_int16_t in <sys/types.h>, which
<unistd.h> includes. However, _using_ that is "unwarranted chumminess"
with the headers; 'man unistd.h' says nothing about any such type.
That header also typedefs:
__uint16_t
__U16_TYPE (actually a macro)
__u_short (and u_short if you #define BSD first)
__u_int16_t
apparently amongst others, equally undocumented in 'man unistd.h'.
The simplest thing would be to set up your own stdint.h header
and
#include "stdint.h"
Set this up so that splint finds your copy of stdint.h and the C compiler
finds the system's copy; add to your copy all the types and macros you
happen to need.
You *really* shouldn't be getting u_int16_t from <unistd.h>
because most UNIX-like systems *don't* define it there and those
that do give you no reason to believe that it will still be there
in the next release. (The obvious thing to do would be to replace
these Linux-specific u_int{N}_tnames by the C99 uint{N}_t names.)
More information about the splint-discuss
mailing list