Bitfields in unions
Eamonn McManus
em at dce.ie
Tue Apr 23 04:47:15 AEST 1991
gvr at cs.brown.edu (George V. Reilly) writes:
>+ 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.
As I mentioned in my original message, K&R2 also seems to imply
obliquely that unions may not contain bitfields. Section A8.3:
...
A struct-declaration-list is a sequence of declarations for the
members of the structure or union:
...
Usually, a struct-declarator is just a declarator for a member of a
structure or union. A structure member may also consist of a
specified numbers of bits. Such a member is also called a
/bit-field/, or merely /field/; its length is set off from the
declarator for the field name by a colon.
struct-declarator:
declarator
declarator[opt] : constant-expression
Although the grammar allows union bitfields, the text by saying `A
*structure* member may also...' seems to be excluding unions. It should
say `A structure or union member...' or just `Such a member...'.
,
Eamonn
More information about the Comp.std.c
mailing list