Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 1997 08:19:29 +0100
From:      Christoph Kukulies <kuku@gilberto.physik.RWTH-Aachen.DE>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        John Milford <jwm@CSUA.Berkeley.EDU>, kuku@gilberto.physik.RWTH-Aachen.DE, freebsd-hackers@freefall.freebsd.org
Subject:   Re: gcc and bitfields
Message-ID:  <19971104081929.11224@gil.physik.rwth-aachen.de>
In-Reply-To: <199711040230.TAA14861@usr09.primenet.com>; from Terry Lambert on Tue, Nov 04, 1997 at 02:30:23AM %2B0000
References:  <199711021618.IAA02063@soda.CSUA.Berkeley.EDU> <199711040230.TAA14861@usr09.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Nov 04, 1997 at 02:30:23AM +0000, Terry Lambert wrote:
> > 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));
> 
> 
> Or you can keep the code portable to DOS by not using the bogus
> GNUish namespace intrusion "__attribute__":
> 
> #pragma pack(1)
>     struct C_OPEN {
>          int a;
>  	int b;
>  	unsigned xdt:1;
>  	unsigned reserved:15;
>     };
> #pragma pack(4)
> /*
>  * GCC will take "pack()" (no arguments) to reset; I don't remember
>  * if MSVC++ can, however... you should check, and use the no argument
>  * version, if possible.
>  */
> 
> 
> Also:
> 	cd /sys/i386/include
> 	grep pragma *.h
> 
> ...there's already precedent favoring "#pragma pack(<N>)" over
> "__attribute__" in FreeBSD.
> 

Yeah, I prefer that also.
But: 

# grep __attrib  *
segments.h:     unsigned sd_lobase:24 __attribute__ ((packed));
segments.h:     unsigned rd_base:32 __attribute__ ((packed));   /* base address  */

> 					Terry Lambert
> 					terry@lambert.org
> ---
> Any opinions in this posting are my own and not those of my present
> or previous employers.

-- 
--Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19971104081929.11224>