On Thursday 08 February 2007 19:42, Linus Torvalds wrote:
<snip>
> Most C types don't, and some you can't even tell (do pointers generate
> "signed" or "unsigned" comparisons? I'll argue that a compiler that
> generates signed comparisons for them is broken, but it tends to be
> something you can only see with a standards- conforming proghram if you
> can allocate memory across the sign boundary, which may or may not be
> true..)
And this is, because as Dennis Ritchie says in "The Development of the C
Language" (http://cm.bell-labs.com/cm/cs/who/dmr/chist.html) C evolved from a
typeless language, B - which, in turn, had originated as a stripped down
version of BCPL. B and BCPL used a "cell addressing" scheme, but because of
the move off the PDP-7, and the difficulties run into by Ken Thompson in
rewriting the code for Unix in B (the original Unix was written in assembler)
types were added - 'char' and 'int'. These represented the byte and word
addressing modes of the PDP-11, and were needed because Ritchie was in the
process of having the compiler generate assembler instead of "threaded code".
This "NB" language, after also having data structures added and the rules for
defining pointers finalized, was renamed "C" by Ritchie.
So almost all the rules around the signs of types are because of a single,
historical machine. Hence the rules about "char" being unsigned by default
and "int" being signed by default are because of the nature of the PDP-11.
The implementation defined nature of bitfields is because Dennis Ritchie had
freedom there - the PDP-11 didn't have anything like them in the hardware and
they were being stuffed in to make Thompsons life easier.
Now: There is no reason for the behavior that came from the nature of the
PDP11 to have survived, but because it was in "The White Book" it made it
through the ANSI standardization process.
Now that this history lesson is over...
DRH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]