From owner-freebsd-hackers Mon Nov 3 23:04:18 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id XAA17513 for hackers-outgoing; Mon, 3 Nov 1997 23:04:18 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from Campino.Informatik.RWTH-Aachen.DE (campino.Informatik.RWTH-Aachen.DE [137.226.116.240]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id XAA17506 for ; Mon, 3 Nov 1997 23:04:14 -0800 (PST) (envelope-from kuku@gilberto.physik.RWTH-Aachen.DE) Received: from gil.physik.rwth-aachen.de (gilberto.physik.rwth-aachen.de [137.226.30.2]) by Campino.Informatik.RWTH-Aachen.DE (8.8.7/RBI-Z14) with ESMTP id IAA25412; Tue, 4 Nov 1997 08:04:04 +0100 (MET) Received: (from kuku@localhost) by gil.physik.rwth-aachen.de (8.8.5/8.6.9) id IAA12703; Tue, 4 Nov 1997 08:19:29 +0100 (MET) Message-ID: <19971104081929.11224@gil.physik.rwth-aachen.de> Date: Tue, 4 Nov 1997 08:19:29 +0100 From: Christoph Kukulies To: Terry Lambert Cc: John Milford , kuku@gilberto.physik.RWTH-Aachen.DE, freebsd-hackers@freefall.freebsd.org Subject: Re: gcc and bitfields References: <199711021618.IAA02063@soda.CSUA.Berkeley.EDU> <199711040230.TAA14861@usr09.primenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81e In-Reply-To: <199711040230.TAA14861@usr09.primenet.com>; from Terry Lambert on Tue, Nov 04, 1997 at 02:30:23AM +0000 Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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()" 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