the one and only objection to C
Jack Jansen
jack at vu44.UUCP
Wed Jan 2 02:44:02 AEST 1985
Re: Alignment problems, etc.
It seems that what is wanted here is something like the
pascal 'packed' attribute.
In a good pascal implementation (well, 'good' in my opinion,
the pascal standard doesn't say what 'packed' should mean
precisely) if you say 'packed' before a record, it stuffs
all the fields adjacent to each other, not caring for word-
boundaries, or 'intelligent alignment' so that the fields
are easily extractable.
This is the way 'packed' is handled in for instance the Sheffield
compiler for the Prime, and all the compilers I know for
the CDC Cyber machines.
The problem is that all the compilers I know for byte-oriented
machines like a PDP or a VAX do it the easy way, i.e. making
every field an integral number of bytes, and aligning the
data to the right in this field.
If we had a precisely defined 'packed' feature in C, or even
a formal definition of the alignment of bitfields
this would be great.
And, in the last case, I think we should *not* be worried about
inefficiency for machines with bytes the wrong way around, etc.
Just make *one* standard. Since bitfields are, as far as I know,
always used for esoteric things like grabbing status bits from
peripherals, etc. the programmer can easily define his bitfields
so that they are reasonably efficient on *his* machine.
--
Jack Jansen, {seismo|philabs|decvax}!mcvax!vu44!jack
or ...!vu44!htsa!jack
If *this* is my opinion, I wasn't sober at the time.
More information about the Comp.lang.c
mailing list