Bitfields in unions
George V. Reilly
gvr at cs.brown.edu
Mon Apr 22 04:45:39 AEST 1991
In article <680 at taumet.com> steve at taumet.com (Stephen Clamage) writes:
+ em at 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 at cs.brown.edu +1 (401) 863-7684
uunet!brunix!gvr gvr at browncs.bitnet Box 1910, Brown U, Prov, RI 02912
More information about the Comp.std.c
mailing list