Date: Sun, 02 Nov 1997 08:18:29 -0800 From: John Milford <jwm@CSUA.Berkeley.EDU> To: Christoph Kukulies <kuku@gilberto.physik.rwth-aachen.de> Cc: freebsd-hackers@freefall.freebsd.org Subject: Re: gcc and bitfields Message-ID: <199711021618.IAA02063@soda.CSUA.Berkeley.EDU> In-Reply-To: Message from Christoph Kukulies <kuku@gilberto.physik.RWTH-Aachen.DE> of "Sun, 02 Nov 1997 16:31:07 %2B0100." <199711021531.QAA04864@gil.physik.rwth-aachen.de>
index | next in thread | previous in thread | raw e-mail
Christoph Kukulies <kuku@gilberto.physik.RWTH-Aachen.DE> wrote:
>
> During porting a piece of a DOS program to make a driver
> for FreeBSD of it for a certain device I'm stuck at the
> point where there is a structure:
>
> struct C_OPEN {
> int a;
> int b;
> unsigned xdt:1;
> unsigned reserved:15;
> }
>
> The sizeof this structure is 10 under DOS (borland C)
> and evaluates to 12 under cc (gcc) on FreeBSD.
>
> There are a lot of these definitions and it would be
> tedious to find a workaround.
>
> Does anyone know if I can pack the structure respectively
> enforce the bitfield to a short int?
By default gcc pads structures to make make the size a multiple of 4 bytes.
Try:
struct C_OPEN {
int a;
int b;
unsigned xdt:1;
unsigned reserved:15;
} __attribute__ ((packed));
--John
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711021618.IAA02063>
