[net.unix-wizards] Lint bug with bit fields

rascal (03/30/83)

I'm getting a error from lint (4.1 BSD, 11/780) on:
	1:	struct packed {
	2:		long
	3:		index:  12,
	4:		offset: 20;
	5:	};
at line 3 and 4: illegal field type.  Of course, cc doesn't complain.
Everything works fine if I change the long to an int.

What's the scoop?  Is it fixed in System V?  Should I forget about
bit fields and define some macros?  (You see, I've made a deal with
my partners to make sure all my code is lint free.)  I need help!

henry (04/01/83)

>From page 197 of Kernighan+Ritchie:

	"The language does not restrict the types of things that
	are declared as fields, but implementations are not required
	to support any but integer fields..."

...and most don't.  This is obviously a place where the compiler
your lint is based on is not quite the same one you get from cc.
I'm afraid it's macro-defining time.  This is just as well if you
are trying to write portable code, as C compilers have a tendency 
towards bugs in bitfield handling.  Dennis Ritchie himself has
described bitfields as "a botch and a blemish".

					Henry Spencer
					U of Toronto