Aligning on some odd address?

Philipp Marek philipp.marek@emerion.com
Thu Apr 16 08:45:00 GMT 2009


Fabian Cenedese <Cenedese <at> indel.ch> writes:
> >You'd lose that memory anyway if the compiler aligns it himself.
> 
> I overlooked the packed requirement, but in that case you can just turn
> it around:
> 
>         struct {
>                 unsigned char dummy[7]; // for 8 byte alignment
>                 unsigned char count;
>                 struct something_else_t array[];
>         }
> 
> Align the struct to 8 bytes and you have your array aligned to 8 bytes.
Yes ... but that wastes a bit of storage, especially if you have several
thousand of these structures, and need to align to 32byte ...

As I can say "align this to 16 byte", I thought I'll ask whether I can say
"align this to 15 (module 16) byte", and maybe get the linker to use the space
before that for some odd data (like ASCIIZ-strings).

Well, thanks anyway.


Regards,

Phil




More information about the Gcc-help mailing list