This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Aligning on some odd address?
- From: Fabian Cenedese <Cenedese at indel dot ch>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 16 Apr 2009 08:44:40 +0200
- Subject: Re: Aligning on some odd address?
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