Is the MapServer code supposed to be ANSI C?

Petter Reinholdtsen pere at HUNGRY.COM
Sat Feb 5 05:00:55 EST 2005


[Steve Lime]
> Hi Petter: Certainly intended to send to the whole list, slip of the
> mouse (CC'ing now). After doing a bit of reading after your initial
> posting I agree that that ANSI C C89 makes the most logical target
> at this point in time.

OK.  This will make it easier to know if the code issues I find are
correct or not.

Am I correct when I believe the code also assume 'char' is a signed
type?  This is undefined in C89, so the code need to be changed to use
'signed char' or 'int8_t' (from <inttypes.h>) to make sure the code
work on all C89-compatible compilers.  The type is signed on i386
archs, and several others as well, and this is the reason I suspect
the code assume 'char' to always be signed.  The code I recently found
with this problem was the 'char classindex' member of
resultCacheMemberObj, which is compared to zero.  This test do not
make sense with some compilers, and the best way to fix this is to
change the type to 'signed char classindex' or 'int8_t classindex' in
map.h.  I suspect this problem exist elsewhere too, but I haven't been
able to locate other problems yet.

As for the -ansi and -pedantic flag, I suggest to start using
-pedantic to get warnings for non-ANSI constructs, and the move on to
include -ansi when the code producing these warnings are fixed to be
C89.



More information about the mapserver-dev mailing list