Bitfields in unions

Mike Lijewski lijewski at theory.tn.cornell.edu
Fri Apr 19 04:06:04 AEST 1991


In article <carbide at dce.ie> 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.

Certainly.  Quoting from 3.5.2.1, "A member of a structure or union may
have any object type.  In addition, a member may be declared to consist of
a specified number of bits (including a sign bit, if any).  Such a member
is called a bit-field;  its width is preceded by a colon."

>Eamonn


-- 
Mike Lijewski  (H)607/272-0238 (W)607/254-8686
Cornell National Supercomputer Facility
ARPA: mjlx at eagle.cnsf.cornell.edu  BITNET: mjlx at cornellf.bitnet
SMAIL:  25 Renwick Heights Road, Ithaca, NY  14850



More information about the Comp.std.c mailing list