function prototype problem

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Nov 18 12:53:19 AEST 1988


In article <1736 at scolex> seanf at sco.COM (Sean Fagan) writes:
>So, the moral of the story:  Don't pass in char's, short's, or float's to
>your subroutines unless you want a Real(tm) ANSI C compiler to choke on it

No, that's the wrong moral.  The correct conclusion is that prototypes
for old-style-defined functions must declare the parameters with the
correctly widened types.  In other words, when converting to prototypes
either convert EVERY reference to a function AND its definition to use
compatible prototypes (in which case any appropriate argument type can be
declared), or else use only widened parameter types.  For example,
	extern double sin(float);
is wrong because for reasons of compatibility the parameter must be
of type double by the time it reaches the innards of the function.



More information about the Comp.lang.c mailing list