[gnu.gcc] Function Problems...

jdp@PacBell.COM (Jerry D. Pierce) (02/13/90)

I'm using gcc 1.36 on a 386 system running under Interactive UNIX
2.0.2 (the latest release) and I'm having problems...

The first code fragment has the function ConvertTemp PRIOR to main,
and it compiles and runs perfectly.

However, if I move the function ConvertTemp AFTER main, I get compile
warning messages and an incorrect value for Celsius is returned...


CODE FRAGMENT 1:
 
float ConvertTemp (float LocalNumber)
{
	return((5.0/9.0) * (LocalNumber - 32.0));
}

main()
{
	float Celsius;

	printf("Farenheit   equals  Celsius\n");
	printf("---------------------------\n");
	Celsius = ConvertTemp(100.00);
	printf("   100\t\t   %6.1f\n", Celsius);
}

Running this code produces:
 
   Farenheit   equals   Celsius
   ----------------------------
      100                 37.8

CODE FRAGMENT 2:

main()
{
	float Celsius;

	printf("Farenheit   equals  Celsius\n");
	printf("---------------------------\n");
	Celsius = ConvertTemp(100.00);
	printf("   100\t\t   %6.1f\n", Celsius);
}

float ConvertTemp (float LocalNumber)
{
	return((5.0/9.0) * (LocalNumber - 32.0));
}


During compilation, code fragment 2 gives me the following error 
messages:
 
progname.c: In function ConvertTemp
progname.c: warning:  'ConvertTemp' was previously implicitly declared to
            return 'int'

Running this fragment (after compilation, of course) produces:

   Farenheit   equals   Celsius
   ----------------------------
      100                -1047643932.0  (!!) 
 
Please, any assistance/pointers would be appreciated.
 
   Jerry Pierce
   pacbell!pbhyf!jdp