>> int foo(short);
>> followed by
>> int foo(x) short x; { ... }
> Why do you use "int foo(short);" in this case ?
Because it's necessary to demonstrate the problem.
> It should be "int foo(int);", because K&R style function definition
> makes short argument to be promoted to int.
Exactly. This is why the definition and prototype are not compatible.
The problem is that old code containing old-style function definitions
is not compatible with prototypes, unless the prototypes specify the
widened argument type. (Or unless you're using gcc.) Why would such
old code exist? First reason: because someone wanted to be
conceptually type-correct even though the language ensured it wouldn't
really happen that way. Second reason: because the programmer didn't
write "short", but rather "uid_t" or "pid_t" or some such, which
happened to be typedeffed to short, likely without the coder knowning.
Or char or float, which produce similar problems.
der Mouse
mouse@collatz.mcrcim.mcgill.edu