Annoying C bug

Joe Kelsey joe at fluke.UUCP
Thu Aug 11 06:52:37 AEST 1983

I have just run across an annoying little bug in the PCC treatment of
bit fields.  It seems that you cannot declare an unnamed bit field in
an "unsigned long" declaration!  "unsigned <anything else but long>"
works just fine!  For example, try declaring:

struct xyzzy {
	unsigned long
		b1 : 1,
		: 1,
		b2 : 1;

and PCC will complain about "illegal field type" at the nameless field.
You can then change the "long" to "int", "short", "char", and no
complaints!  You can also use just "unsigned" with no qualifier and it
also works.  This caused me some grief when I started using "unsigned
long" for 32-bit wide bit field definitions for consistency with my
other declarations of "unsigned short", etc.  This is only an
annoyance, since there is a work-around, but it seems that PCC is
acting rather inconsistently.


More information about the Comp.lang.c mailing list