At 01:42 PM 9/18/2002 +0200, you wrote:
>Hi all.
>
>A while back I think I may have asked questions in this forum about if
>anyone had seen FntSetFont not work. Well, a colleague of mine had
>something similar a week or two ago, and he was able to come up with a
>reason why, after hearing about how I'd worked around it... According to
>him, if you have a CodeWarrior project in which you enable the setting to
>force enums to be ints, then for example, the boldFont enum becomes a 16 bit
>wide int, and with the endianess of a dragonball, you then lose the
>significant bits when calling FntSetFont, as it forces its font-type-enums
>to be 8 bits wide. That seems very plausible to me, though I am astonished,
>if that's true, that a call to FntSetFont would link at all, but that's
>another story...
Yes, the Palm OS API headers rely on the "enum is always int" setting to be
off. As for linkage -- there isn't a real link going on for the Palm OS
API functions, like you'd see on Windows where system APIs get linked
through DLLs. All of the APIs are really declared as tiny inline sets of
68K assembly instructions that use a TRAP instruction to jump into the
operating system. Since FntSetFont uses FontID as its parameter, the type
varies depending on the "enums always int" setting.
Now the stack conventions of Palm OS come into play. All arguments to
system functions are pushed on the stack, and the stack is always 16-bit
aligned. If you push a 8-bit value, the system pushes a byte, then a
filler byte. If you push a 16-bit value, you push the high byte and then
the low byte. Result: the stack looks different depending on the size of
the parameter.
So, your partner is correct. 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.
--
Ben Combee
CodeWarrior for Palm OS Platform technical lead
[EMAIL PROTECTED]
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/