From: "Jamie Macleod" <[EMAIL PROTECTED]>
Subject: sizeof(DateType) == 2 ?

> Can someone explain why sizeof(DateType) gives me 2?  DateType is a
> structure declared as 3 UInt16 values, and of course if I do a
> (sizeof(UInt16) * 3) I get 6.  Shouldn't I be getting 6 for DateType?

DateType is not a structure with 3 UInt16s.  It is a single UInt16 used as a
bit field (16 bits, 2 bytes).

typedef struct {
  UInt16 year :7;
  UInt16 month :4;
  UInt16 day :5;
} DateType;

7 bits are used for the year, 4 bits for the month, and 5 bits for the day.

You might want to pick up a book on C.



-- 
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