johnezang/JSONKit — pull request #57 by MikeWeller (2011-11-15 15:35:26+00:00)
Title: Fixes warnings when compiling with -Wconversion and -pedantic etc.

We compile with very strict compiler options, most notibly -Wconversion which will warn about any implicit conversions between signed and unsigned as well as when an integer is casted down in size.

I added a bunch of explicit casts to get rid of these warnings. I took care to examine the code and make sure the casts make sense. In all cases the behaviour is unchanged, although I don't have any unit tests to run (see Issue #56). We're just making the implicit casts explicit.

I also fixed a few other problems:

The commits:

Commit 1 adds an additional check for __STRICT_ANSI__ to __GNUC__ to decide between the stubbed out macros like JK_ATTRIBUTES and the real versions. clang will define __GNUC__ even when compiling with -pedantic mode where some of the GNUC features are not allowed (like certain comma pasting and macro varargs stuff)

Commit 2 fixes a warning about unused varargs in the stub version of the JK_ATTRIBUTES macro. This is a silly warning but we can just remove the first argument since the whole thing is a NOP anyway.

Commit 3 Fixes a bunch of implicit sign conversion warnings when using ~ to remove a flag. ~ will return a signed integer so we cast the result to the flag type we want. An alternative would be to declare JKFlags as NSInteger but I thought this is was better choice since all the flag values should be generated as unsigned by the compiler.

Commit 4 replaces the non-standard triple-dot '...' style cases. Ugly but follows standards.

Commit 5 fixes all the implicit conversions between different pointer sizes and signedness.

Cheers,

Mike