Mail Archives: djgpp/1996/08/18/14:46:04
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'.
- Raw text -