"James Nicholls" <[EMAIL PROTECTED]> wrote in message
news:45103@palm-dev-forum...
>
> Hi all, I've got a structure defined in CodeWarrior C++ as:
>
> struct T
> {
>   UInt32 f1 : 24;
>   UInt8  f2;
> };
>
> This structure is meant to treat the first three bytes of memory as a
unit
> and the following byte as another unit inside of a 4 byte word.
sizeof(T)
> == 6.  WHY DOESN'T EQUAL 4!!??

In C, all the bitfield members need to be declared using bitfield
notation.  Your structure defintion should say

struct T
{
  UInt32 f1 : 24,
         f2 : 8;
};

Your declaration had a UInt32 bitfield with 24 defined bits and 8
padding bits.  This one actually defines names for all 32 bits, which is
what you want.
--
Ben Combee, [EMAIL PROTECTED]
Techwood Broadcasting Foundation, Austin Bureau



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to