This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On alignment
On 23 Apr 2003 12:11:24 -0600, Tom Tromey <tromey at redhat dot com> wrote:
>>>>>> "Jason" == Jason Merrill <jason at redhat dot com> writes:
>
> [ about struct foo { double x; } ]
>
> Tom> I'd like to find the most future-proof way to do this. In the above,
> Tom> is __alignof__(foo::x) the best way? I'm only concerned with
> Tom> alignment of fields.
>
> Jason> It is since my recent patch to do all alignment calculation for
> Jason> fields in layout_decl.
>
> I can't do this.
>
> struct aligner { double field; };
>
> int compute () { return __alignof__ (aligner::field); }
Ah, no, you need to do something like
#define FIELD_ALIGNOF(TYPE) __alignof (((struct { TYPE t; } *)0)->t)
Jason