using floats in functional prototypes

Larry Jones scjones at sdrc.UUCP
Fri Jan 20 08:36:24 AEST 1989


In article <1989Jan18.092522.14499 at gpu.utcs.toronto.edu>, romwa at gpu.utcs.toronto.edu (Royal Ontario Museum) writes:
> When I compile the two files, I get a warning that the type of
> the argument in the prototype doesn't match the declaration
> 
> void afunc( float );
> 
> void afunc( flt_val )
> float flt_val;
> {
>   int i;
> 
>   i = 3;
> }

The problem is that you have witten the function definition using
the old-style syntax.  When you do that, the function expects to
be called with widened arguments (i.e. the float argument will
actually be passed as a double).  To fix the problem, either
change the float in the prototype to double or write the
definition using prototype form:

	void afunc( float flt_val )
	{
	}

----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at sdrc.UU.NET
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150                  AT&T: (513) 576-2070
"When all else fails, read the directions."



More information about the Comp.lang.c mailing list