Aligning on some odd address?
Fabian Cenedese
Cenedese@indel.ch
Thu Apr 16 06:44:00 GMT 2009
At 08:38 16.04.2009 +0200, Philipp Marek wrote:
>Hello everybody,
>
>I'd like to know whether there's some way to get a structure aligned on a non-
>aligned address.
> struct {
> unsigned char count;
> struct something_else_t array[];
> }
>
>Now I'd like to have the array (where each element has eg. 16, 32, or 48
>bytes) aligned - on at least a 4 byte boundary, but better still on 8/16/64
>bytes.
Why don't you fill in dummy members to get the correct alignment?
Like
struct {
unsigned char count;
unsigned char dummy[7]; // for 8 byte alignment
struct something_else_t array[];
}
You'd lose that memory anyway if the compiler aligns it himself.
bye Fabi
More information about the Gcc-help
mailing list