Func Protos with K&R Func Defs

Henry Spencer henry at zoo.toronto.edu
Fri Mar 1 04:35:17 AEST 1991


In article <1991Feb28.021715.18153 at athena.mit.edu> jik at athena.mit.edu (Jonathan I. Kamens) writes:
>  In ANSI C, a function declaration must match its definition.  That means
>that if the declaration is prototyped, then the definition must also be
>prototyped, with the same types; if the declaration is not prototyped, then
>the definition cannot be prototyped either.

Not so.  The types of declaration and definition must match, after some
complicated considerations of default argument promotions etc. are taken
into account.  But there is no requirement that use and definition match
in the sense of using prototypes.  It is quite permissible to provide
a prototype for an old-style function or use a new-style definition for 
an unprototyped function.  You just have to know what you are doing; it
is not quite as easy as it looks.  The example Jonathan gives is indeed
illegal, but it's simple to fix it.
-- 
"But this *is* the simplified version   | Henry Spencer @ U of Toronto Zoology
for the general public."     -S. Harris |  henry at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list