Bitfields in unions

Stephen Clamage steve at taumet.com
Sun Apr 21 08:01:35 AEST 1991


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.

The alignment argument is irrelevant, as it is up to the compiler to see
that an object of union type is aligned suitably.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.std.c mailing list