__attribute__ and built-in types

Steve Hanka shanka@nact.com
Mon Oct 4 07:43:00 GMT 1999


Hi,

We have been trying to use the "__attribute__((aligned(4)))"  in gcc
2.8.1 to force structure field alignment in data being passed between an
MC68060 target and a PowerPC MPC860 target.  We have noticed that when
we use "__attribute__ ((aligned(4))) on the MC68060 target,
pre-initialized global variables give an error from the assembler
indicating that the requested alignment is larger than that allowed for
the architecture.

That is not the bug I want to report, however.  The above error brought
up the fact that the statement

typedef long __attribute__ ((aligned(sizeof long)))) AlignedLong;

will assign the aligned attribute to all variables of type long
thereafter.  This causes grief on our MC68060 target's global variables
of type long - no file with global variables of type long that include
the above declaration will compile.

We have a work-around:

typedef long JunkLong;

typedef JunkLong __attribute__ ((aligned(sizeof JunkLong))) AlignedLong;

Using the intermediate type of JunkLong prevents the modification of the
attributes of type long, and files containing global variables of type
long will compile even when the above declaration is included.

Perhaps this is not a bug, but it seems to me that a typedef statement
should not modify the attributes of the native types of the language.

-- Steve Hanka
Software Engineer
NACT Switching Division
World Access, Inc.
shanka@nact.com






More information about the Gcc-bugs mailing list