At 02:56 PM 9/19/2002 +0200, you wrote:
> > Yes, the Palm OS API headers rely on the "enum is always int" setting
> to be
> > off. [...] For this reason, when I declare my own enums
> > on Palm OS, I like to just typedef the appropriate ranged type to the
> "enum
> > type", and leave all my enums as a anonymous type, e.g.
> >
> > enum { red, blue. green }; typedef UInt8 Color;
> >
> > That makes sure my type has exactly the size I want it to have.
>
>Unfortunately it also makes debugging harder (you don't see the symbolic
>values of your variables) and subverts the compiler's ability to provide
>type checking and other diagnostics: there's a significant loss of type
>checking in C++, and even in C this technique prevents such things as
>having the compiler check that you've covered all cases in a switch like
>"switch (myColor)" (this is GCC's -Wswitch option).
>
>IMHO the disadvantages outweigh the advantage Ben listed.
Agreed -- I prefer enums, but use that method if I'm developing code that
might be run on platforms different from the intended. I probably wouldn't
use that on Palm OS, but I might use that style to represent a Palm OS enum
being manipulated in a Win32 process, for example. I, for one, love being
able to right click on a type and say "View as Enum" and have that work in
my debugger.
--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/