Mail Archives: djgpp/1995/05/07/10:12:04
> i'm having an interesting problem. i have the following struct that i am
> reading in from a file:
>
> char attrib;
> unsigned short int numkeys;
> unsigned long left;
> unsigned long right;
> char continue;
> char *keys;
>
> the file physically reads as follows:
>
> hex: "01 F0 00 00 00 00 00 00 00 00 00 00 00 06 00 00 30 32 . . ."
>
> somehow a byte is getting lost, and it doesn't make much sense. i could
That's because the compiler is free to pad structure fields to make
memory accesses more efficient. If you want to make the structure
packed (i.e. that its sizeof will be 13), use the __attribute__((packed))
extension of GNU C (it's in the docs).
- Raw text -