Reference: <
http://www.lysator.liu.se/c/ten-commandments.html>,
written by Henry Spencer.
The original version of this fine document was written, I believe,
before the existence of ANSI C. The Third Commandment is:
Thou shalt cast all function arguments to the expected type if
they are not of that type already, even when thou art convinced
that this is unnecessary, lest they take cruel vengeance upon thee
when thou least expect it.
The newer annotation reads, in part:
It may be thought that the radical new blessing of ``prototypes''
might eliminate the need for caution about argument types. Not so,
brethren. Firstly, when confronted with the twisted strangeness of
variable numbers of arguments, the problem returns... and he who
has not kept his faith strong by repeated practice shall surely
fall to this subtle trap. Secondly, the wise men have observed
that reliance on prototypes doth open many doors to strange
errors, and some indeed had hoped that prototypes would be decreed
for purposes of error checking but would not cause implicit
conversions. Lastly, reliance on prototypes causeth great
difficulty in the Real World today, when many cling to the old
ways and the old compilers out of desire or necessity, and no man
knoweth what machine his code may be asked to run on tomorrow.
This was good advice *at the time it was written*. Today, C compilers
that don't support prototypes are vanishingly rare, and this advice is
IMHO obsolete. You still need to be careful when calling variadic
functions; for example, when passing a pointer to printf with the "%p"
format, you should cast it to void*. (Quibbles: If it's already
void*, you don't need to cast it; if it's char*, you can probably get
away without casting it, but you should anyway; if it's a function
pointer, you can't portably print it with "%p" with or without a
cast.)