Ben Combee <[EMAIL PROTECTED]> wrote:
> At 09:55 PM 11/11/2003, Luc Le Blanc wrote:
>> Can I do the same to read the gadget data with FrmGetGadgetData or do I
>> absolutely have to use a union?
I don't understand. Why *wouldn't* you want to use a union?
> Try
>
> UInt32 data = (UInt32) FrmGetGadgetData( ...);
> UInt16 val1 = data >> 16;
> UInt16 val2 = data & 0xFFFF;
>
> to extract the values.
You can do that bit-twiddling everywhere manually, or you can use a
union and have the compiler do it for you. What's the downside?
(Yes, you should probably add "assert (sizeof (struct GadgetData) ==
sizeof (void*))" somewhere, but you need to do that with the manual
alternative too.)
John
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/