enums and bitfields

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Sep 15 06:33:02 AEST 1990


In article <3119 at isaak.isa.de> gutjahr at isa.de (Bernd Gutjahr) writes:
>	struct {
>		enum bool flag : 1;
>	} s;

Since this violates the Semantics in 3.5.2.1 ("A bit-field shall have a
type that is a qualified or unqualified version of one of int, unsigned
int, or signed int), there isn't much more that can be said about what
is required according to the C standard.  According to 1.6, this is
explicitly a case in which behavior is undefined.  Thus no strictly
conforming program may use this construction.  An implementation that
adds this as an extension need not produce a diagnostic message, but
for more details about the rules you would have to consult the
implementation's specific documentation to find out what the rules are.
However,
>	unsigned enum bool flag : 1;
would violate a combination of syntax rules that basically prohibit
attempts to use enum-specifiers with "unsigned" in them in general,
not only as the declarator in a struct-declarator.



More information about the Comp.std.c mailing list