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: Atrribute packed and aligned causes alignment trap on ERC32(SPARC v7)


Hi Ulf,

In your situation, don't use a C bitfield.

Use a C char for your struct data member, where the lsb (or msb) is your bit of interest, and the other 7 bits are fallow.

On most platforms, a C char is an octet (8 bits).  It has the packing you want, without using GCC-isms to contort a natural machine word (i.e., an int) into unaligned access (as you are doing with your bitfield struct).

Some architectures do not work with unaliagned word access.

HTH,
--Eljay


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