This is a structure alignment problem. On the Palm Words are alligned on a 
2 byte boundary. So your wFieldAttribute field actually starts at offset 18 
and not 17. You could reorder your structure like this:

typedef struct
{
     Word        wFieldAttribute;
    Word wFieldLength;
   Char  cFieldName[16];
    Char  cFieldType;
    UChar cFieldDecimal;
    UChar ucFieldOffset;
} FIELD_DEF;

and then get 23 bytes

Chris

At 12:01 PM 12/22/1999 +0800, you wrote:
>Hi all,
>
>This seems basic but somehow I got different answer for it:
>
>typedef struct
>{
>    Char         cFieldName[16];
>    Char  cFieldType;
>    Word wFieldAttribute;
>    Word wFieldLength;
>    UChar cFieldDecimal;
>    UChar ucFieldOffset;
>} FIELD_DEF;
>
>I sizeof all the structure members and it returns me 23.
>sizeof(FIELD_DEF) will return me 24 bytes, instead of 23.
>Why is it so? Where does the one extra byte come from?
>
>Thanks,
>garry
>

---
Christian Vandendorpe ([EMAIL PROTECTED])
http://www.zorglub.com

Reply via email to