Bit field differences

pat pat
Tue Apr 5 11:23:33 AEST 1983

Our 4.1 VAX compiler assigns bit fields from right to left,
ie. from low order to high,
while the 68000 compiler from MIT assigns bit fields from left to right,
ie. from high order to low.  So,

to set bit 15 on the VAX
		unsigned short unused:15,

	foo.bit = 1;

to set bit 15 on the 68000
		unsigned short bit:1;

	foo.bit = 1;

The C reference manual says
"Fields are assigned to words ... right-to-left on the PDP-11 and
left-to-right on other machines" so the VAX compiler is "wrong".
Of course the manual also says that it "describes the C language
on the DEC PDP-11, the Honeywell 6000, the IBM System/370, and the
Interdata 8/32", so maybe this is what they mean by other.
If I were writing a C compiler I would put 
a high value on maintaining  compatability with PDP-11s, so I'd say that
MIT took the standard a bit too literally.

More information about the Comp.lang.c mailing list