mcgrath@tully.Berkeley.EDU (Roland McGrath) (05/14/89)
This seems to be a common problem, so read this and remember it!
You cannot intermix traditional (non-prototype) definitions and prototype
declarations of functions whose arguments are of types that get widened.
In C, [unsigned] short and char get widened to [unsigned] int, and float
gets widened to double, normally.
However, in the presence of a prototype declaration, the compiler does NOT
do this widening, since both the function and the caller know exactly what
types are being used.
The non-prototype definition:
void
func(x)
short x;
{ ... }
is essentially equivalent to:
void
func(temp)
int temp;
{
short int x = (short) temp;
}
The solution to your problem is to either write the prototypes with the
widened types:
void f1(int a1);
void f2(double a2);
or to write your functions with prototype definitions:
void f1(short a1) { ... }
void f2(double a2) { ... }
--
Roland McGrath
Free Software Foundation, Inc.
roland@ai.mit.edu, uunet!ai.mit.edu!roland
Copyright 1989 Roland McGrath, under the GNU General Public License, version 1.