Parameter Types in Old-Style Function Definitions

Walter Bright bright at Data-IO.COM
Tue Sep 11 04:30:11 AEST 1990


In article <1990Sep8.053408.2005 at alphalpha.com> nazgul at alphalpha.com (Kee Hinckley) writes:
<Consider the following function, defined in K&R:
<
<	foo(c, i)
<	char	c;
<	int	i;
<	{}
<Clearly the function expects to pick two ints up off of the stack.
<
<Now consider the same function, declared and used from ANSI C (or C++).
<	extern foo(char c, int i);
<
<So I guess the question is.  Does the ANSI spec mandate that the above be
<compatible, mandate that they aren't, or not say?

They are *NOT* compatible. The prototype for the first one is:
	int foo(int,int);
which is not the same as:
	int foo(char,int);
even though some compilers allow this.



More information about the Comp.std.c mailing list