Nothings wrong, the compiler will be padding the structure out to ensure
that it is word aligned. On 68K machines data must be word aligned (this
does not matter for chars though). This structure does not actually need to
word aligned, but if you had one with int data1[10] and then char data2[1],
if you were to have an array of these, the structures with the odd indexs
would cause bus errors when you read the words as they are not aligned on a
even address. The rule is simple : Datatypes bigger than 1 char, must start
on a even address.

Rik

> -----Original Message-----
> From: J.J [SMTP:[EMAIL PROTECTED]]
> Sent: 30 July 2001 09:14
> To:   Palm Developer Forum
> Subject:      struct size error(sizeof Error?)
> 
> Hi!
> 
> 
> I'm define my source below that 
> 
> 
> int size;
> 
> typedef struct test
> {
>       char    data1[10];
>       char    data2[1];
> }my_test;
> 
> size = sizeof(my_test);
> 
> 
> I guess the value of size is "11" but, size value is "12"
> 
> 
> What's wrong???
> 
> I'm using CodeWarrior 7.
> Please Help....
> 
> 
> £¿£¿+£¿b£¿'ºÈ£¿£¿=£¿
> ëÞ£¿^£¿+£¿(®Ú.£¿£¿Êâm£¿y?±ç¡¶£¿?0¥©f¢Ç(£¿^¿û^r캣¿®ßߢ»¦

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