Date: Tue, 4 Nov 1997 02:30:23 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: jwm@CSUA.Berkeley.EDU (John Milford) Cc: kuku@gilberto.physik.rwth-aachen.de, freebsd-hackers@freefall.freebsd.org Subject: Re: gcc and bitfields Message-ID: <199711040230.TAA14861@usr09.primenet.com> In-Reply-To: <199711021618.IAA02063@soda.CSUA.Berkeley.EDU> from "John Milford" at Nov 2, 97 08:18:29 am
index | next in thread | previous in thread | raw e-mail
> 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.
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711040230.TAA14861>
