This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Aligning on some odd address?


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]