Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!apple!bloom-beacon!shelby!agate!tully.Berkeley.EDU!mcgrath From: mcgrath@tully.Berkeley.EDU (Roland McGrath) Newsgroups: gnu.gcc.bug Subject: Re: prototyping short and float --- READ THIS Message-ID: Date: 13 May 89 19:58:17 GMT References: <8905131941.AA16561@troilus.stolaf.edu> Sender: usenet@agate.BERKELEY.EDU Distribution: gnu Organization: Hackers Anonymous International, Ltd., Inc. (Applications welcome) Lines: 43 In-reply-to: tuecke@TROILUS.ACC.STOLAF.EDU's message of 13 May 89 19:41:35 GMT 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.