This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On alignment
- From: "Kevin B. Hendricks" <kevin dot hendricks at sympatico dot ca>
- To: gcc at gcc dot gnu dot org,aph at redhat dot com,jason at redhat dot com
- Date: Tue, 25 Mar 2003 11:22:13 -0500
- Subject: Re: On alignment
Hi,
> struct B : A {
> // force normal alignment
> char : 0 __attribute ((__aligned (__alignof (A))));
> short bs;
> };
FWIW:
If I am not mistaken, a similar approach was used by OpenOffice.org when trying to support
both gcc 2.9.5X components and gcc 3.X components
Here is a piece of the cppu component test code:
#define CPPU_GCC3_ALIGN( base_struct ) __attribute__ ((aligned (__alignof__ (base_struct))))
struct C1
{
signed short n1;
};
struct C2 : public C1
{
signed long n2 CPPU_GCC3_ALIGN( C1 );
};
...
struct M
{
signed long n;
signed short o;
};
struct N : public M
{
signed short p CPPU_GCC3_ALIGN( M );
};
Kevin