Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!brunix!gvr From: gvr@cs.brown.edu (George V. Reilly) Newsgroups: comp.std.c Subject: Re: Bitfields in unions Message-ID: <72969@brunix.UUCP> Date: 21 Apr 91 18:45:39 GMT References: <680@taumet.com> Sender: news@brunix.UUCP Reply-To: gvr@cs.brown.edu (George V. Reilly) Organization: Dept. of Computer Science, Brown University, Providence RI Lines: 18 In article <680@taumet.com> steve@taumet.com (Stephen Clamage) writes: + em@dce.ie (Eamonn McManus) writes: + + >Can a union contain a bitfield? K&R2 obliquely implies no, while + >gcc -pedantic says yes. I'm inclined to believe K&R myself, though + >at least on machines without alignment constraints such a thing + >would seem reasonable. + + The ANSI C standard says explicitly that a union may contain a bitfield. Well, that's another thing that Harbison & Steele III have got wrong, then. On p. 128, it says: The syntax for defining components [in unions] is the same as that used for structures, except that bit fields are not permitted in unions. ________________ George V. Reilly `Strike breaker' gvr@cs.brown.edu +1 (401) 863-7684 uunet!brunix!gvr gvr@browncs.bitnet Box 1910, Brown U, Prov, RI 02912