> > __attribute__((packed))
>
> Does not work. (2.7.2)
Does, if you pack the whole structure.
The below example
struct pak {
char byte;
long dword;
} __attribute__((packed));
xxx (struct pak *pak) {
return sizeof(*pak);
}
Compiled with (gcc-2.7.2.1)
# gcc -S -O2 packed.c
Gives
xxx:
pushl %ebp
movl %esp,%ebp
movl $5,%eax
^^^^
which is (what I guess) just what you want ( sizeof(char) + sizeof(long) ).
Packing the whole structure leads to byte alignment for all members within
the structure, hence you are free to privately align by inserting dummy
byte variables into the structure.
Hans
<lermen@fgan.de>