Date: Mon, 03 Nov 1997 11:31:24 +1030 From: Mike Smith <mike@smith.net.au> To: jbryant@tfs.net Cc: jwm@CSUA.Berkeley.EDU (John Milford), freebsd-hackers@freebsd.org Subject: Re: gcc and bitfields Message-ID: <199711030101.LAA00660@word.smith.net.au> In-Reply-To: Your message of "Sun, 02 Nov 1997 16:13:20 MDT." <199711022213.QAA00245@argus.tfs.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711030101.LAA00660>