This is the mail archive of the gcc@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: 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


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