Barry Schwarz said:
On Sun, 15 Feb 2009 15:59:59 +0800, WANG Cong
snip
I can't say for certain but I'm almost positive that C started with a
char type in addition to int so it could handle strings.
Yes, as well as float and probably double.
In any event, early versions of C (up to at least C89) had implied int
for declarations that didn't specify. So
int getchar(void);
was exactly the same declaration as
getchar(void);
From there, it seems a very small leap to conclude that
unsigned int x;
is the same as
unsigned x;
I think this is the more likely explanation.
[...]
C's ancestor languages, BCPL and B, had no real types other than a
16-bit word. Here's a sample function from Ken Thompson's "Users'
Reference to B", via Wikipedia:
/* The following function will print a non-negative number, n, to
the base b, where 2<=b<=10, This routine uses the fact that
in the ASCII character set, the digits 0 to 9 have sequential
code values. */
printn(n,b) {
extrn putchar;
auto a;
if(a=n/b) /* assignment, not test for equality */
printn(a, b); /* recursive */
putchar(n%b + '0');
}
Note that the declaration of putchar doesn't even specify that it's a
function.
Early C retained the ability to declare parameters and variables
without specifying their types; since C's int corresponding to B's
word, the implicit int rule made sense.
Pre-ANSI C added the ability to specify types other than int, and the
requirement to distinguish between variables and functions. ANSI C,
of course, added function prototypes, but didn't require them, and
implicit int wasn't dropped until C99.
I can get the above to compile as C either by changing
extrn putchar;
to
extern putchar();
or just by deleting that line.