This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Atrribute packed and aligned causes alignment trap on ERC32(SPARC v7)
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Ulf Ivraeus <ulf dot ivraeus at space dot se>, gcc-help at gcc dot gnu dot org
- Date: Mon, 30 May 2005 14:13:33 -0500
- Subject: Re: Atrribute packed and aligned causes alignment trap on ERC32(SPARC v7)
- References: <200505300800.j4U80KAQ003202@space.se>
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