Newsgroups: comp.std.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!theory.tn.cornell.edu!lijewski
From: lijewski@theory.tn.cornell.edu (Mike Lijewski)
Subject: Re: Bitfields in unions
Message-ID: <1991Apr18.180604.14097@batcomputer.tn.cornell.edu>
Sender: news@batcomputer.tn.cornell.edu
Nntp-Posting-Host: theory.tn.cornell.edu
Organization: Cornell National Supercomputer Facility
References: <carbide@dce.ie>
Date: Thu, 18 Apr 1991 18:06:04 GMT

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

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@eagle.cnsf.cornell.edu  BITNET: mjlx@cornellf.bitnet
SMAIL:  25 Renwick Heights Road, Ithaca, NY  14850
