Gregg Woodcock <[EMAIL PROTECTED]> wrote:
> I cannot run gcc compile with "-pedantic" as the Palm SDK are non-compliant
> with strict ANSI C standards. The big offender is non-int enums declared
> like this:
> typdef enum { UP, DOWN, LEFT, RIGHT } DirectionType;
> instead of like this:
> typdef enum { UP = (int)0, DOWN, LEFT, RIGHT } Direction Type;
> so as to explicitly confirm to ANSI standard of enums as "int".
I have no idea what you are talking about. Your example is entirely
compliant (modulo typos), and your suggested fix would have no conceivable
effect even if it were not.
Presumably you are referring to
warning: ANSI C restricts enumerator values to range of `int'
which appears 11 times when you compile the 5.0 R3 headers with -pedantic.
(This would have been *so* much easier if you had just *shown us* the
diagnostic message that was of concern.)
There is a point of view that says this warning should not appear for
code in a system header (in the absence of -Wsystem-headers). Indeed,
later versions of GCC do suppress this warning in system headers, like
they suppress other similarly trivial warnings in system headers. So
this could be construed as a bug in the 2.95.3 GCC we are using on m68k
Palm OS; perhaps someone will look into it, and certainly the diagnostic
would go away with a new compiler version.
The code in question is of the form
enum { foo = 0x8000 };
and the warning refers to the fact that, in portable C, enumerators can
be no bigger than ints, and in the m68k Palm OS ABI ints are 16 bits.
But, when it comes from the Palm OS SDK headers, this is not an especially
interesting warning because code that uses the Palm OS SDK headers is not
particularly portable beyond Palm OS, and all Palm OS C compilers in fact
support the extension of allowing larger enumerators. And the Palm OS SDK
headers depend on this -- in 11 places.
Now let's look at the value of such an enumerator:
long bar() { return foo; }
This function returns 32768, of course. But when compiled with -pedantic,
GCC 2.95.3 emphasizes the undefined behaviour by having bar() return 0.
Thus using -pedantic has changed the meaning of your program. This is,
to be sure,... surprising. But it means that using -pedantic on Palm OS
in production builds is probably a mistake, especially if you use any of
those 11 enumerators.
Welcome to Palm OS. Doctor, it hurts when I use -pedantic. Well, don't
do that then.
John
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/