Date: Sun, 18 Aug 1996 12:40:37 -0600 (MDT) From: The Lost Wizard of Absolutely Nothing To: djgpp AT delorie DOT com Subject: Re: What am i doing wrong? In-Reply-To: <199608181702.AA28727@mail.umu.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 18 Aug 1996, Andreas Vernersson wrote: > Could anyone explain this? > > typedef struct a > { unsigned int q2 __attribute__((packed)); > unsigned char qq __attribute__((packed)); > } b; > > typedef struct a2 > { > unsigned int q2; > unsigned char qq; > } b2; > > > void main() > { > printf("size: %d\n",(int)sizeof(b)); // 5 ??? > printf("size: %d\n",(int)sizeof(b2)); // 8 ??? > } > > > ---- > I only wants the datastructure to be 2+1=3 bytes... > In DJGPP, an int is 32 bits which is four bytes. If you want a 16 bit integer, I suggest using `short' instead of `int'.