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: attribute aligned(4) ignored


Chris Lattner <sabre@nondot.org> writes:

> > How about
> >
> >   double D __attribute__((aligned(4), packed));
> 
> This is exactly the sort of thing I want to do.  My structs can be
> arbitrarily complex, and can have a bunch of stuff in them that should
> not be packed.  This means that I don't want to use attribute packed
> on the structure itself, but using it on the member would be fine.
> 
> However, when I try this:
> 
> struct Test {
>    double D __attribute__((packed,aligned(4)));
>    short X;
> };
> 
> ... the struct maintains its 8-byte alignment even though nothing
> inside of it requires 8-byte alignment any more.

When I try that with a powerpc-eabi compiler, it appears to generates
a struct with a size of 12 bytes and an alignment of 4 bytes.  Do you
not see that with a Darwin compiler?  What target are you configuring
for?  What sources are you using?

Ian


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