Parameter Types in Old-Style Function Definitions
Doug Gwyn
gwyn at smoke.BRL.MIL
Mon Sep 10 07:15:10 AEST 1990
In article <1990Sep8.053408.2005 at alphalpha.com> nazgul at alphalpha.com (Kee Hinckley) writes:
>foo(c, i)
>char c;
>int i;
>{}
>extern foo(char c, int i);
These are not guaranteed to be compatible, since the definition uses
default-widened parameter types but the prototype declaration uses
unwidened (in general) types. Implementations that always default
widen arguments even for new-style functions linkage will probably
support this mixture, but other implementations will not.
The general coding rule for fixed-argument functions is:
EITHER always use already-default-widened parameter types
OR ELSE always use prototypes, never old-style declarations
or definitions
(For variable-argument functions, always use prototypes including ",..."
and use appropriate <stdarg.h> macros in the function definitions.)
If you try to mix old- and new-style syntax, you risk running afoul
of the genuine differences in linkage for the two styles.
More information about the Comp.std.c
mailing list