From owner-freebsd-hackers Sun Nov 2 17:05:30 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id RAA23122 for hackers-outgoing; Sun, 2 Nov 1997 17:05:30 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from word.smith.net.au (vh1.gsoft.com.au [203.38.152.122]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id RAA23116 for ; Sun, 2 Nov 1997 17:05:24 -0800 (PST) (envelope-from mike@word.smith.net.au) Received: from word.smith.net.au (localhost.gsoft.com.au [127.0.0.1]) by word.smith.net.au (8.8.7/8.8.5) with ESMTP id LAA00660; Mon, 3 Nov 1997 11:31:25 +1030 (CST) Message-Id: <199711030101.LAA00660@word.smith.net.au> X-Mailer: exmh version 2.0zeta 7/24/97 To: jbryant@tfs.net cc: jwm@CSUA.Berkeley.EDU (John Milford), freebsd-hackers@freebsd.org Subject: Re: gcc and bitfields In-reply-to: Your message of "Sun, 02 Nov 1997 16:13:20 MDT." <199711022213.QAA00245@argus.tfs.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 03 Nov 1997 11:31:24 +1030 From: Mike Smith Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > > 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. > > ahem, DOG should show 6 bytes. Yup, I missed this earlier. > since he apparently uses 16 bits in the bitfield, I can assume that to > be a short. > > thus: > > > struct C_OPEN { > > int a; > > int b; > > unsigned short xdt:1; /* note addition of short */ > > unsigned short reserved:15; /* note addition of short */ > > } __attribute__ ((packed)); > > should work. Nope, but closer again. Unless he's using a BCC option to default his 'int' type to 32 bits (which *would* explain the initial size being 10), he wants: struct C_OPEN { short a; short b; ... mike