Mail Archives: djgpp/1996/08/19/09:45:21
In article <199608181702 DOT AA28727 AT mail DOT umu DOT se>, hubble AT hem DOT passagen DOT se (Andreas Vernersson) writes:
<Removing blank lines>
> 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...
Since djgpp is a 32-bit system, ints (and longs) are 32 bits, ie 4
bytes. You should use short instead of int (or short int, but who
types that? :) )
Adoxa <hoodj AT topaz DOT cqu DOT edu DOT au>
- Raw text -