matsl@nada.kth.se (Mats Luthman) (05/31/88)
I have about 20000 lines of code in which there are a lot of functions with parameters of type float. The files typically look something like this: #ifdef PROTOTYPES extern void foo(float f); #else extern void foo(); #endif void foo(f) float f; { printf("%f\n", f); } void bar() { foo(17.0); } Rumours tell that some compilers are able to generate code that does not convert floats to doubles when evaluating expressions, so we want to have it this way (actually, the previous version of Turbo C, 1.0, did not convert floats when passing them as parameters in this way). A major flaw in version 1.0 was that parameters of type float were always converted to double when there was no prototype, but not converted back to floats inside the functions if they were declared as such, which made a lot of existing code break. Now, with version 1.5, this has been changed so that code without prototypes works, but code with separate prototypes, like the code above, does not. The above example generates the message: Error tst.cc 10: Type mismatch in parameter 'f' in function foo This works: void foo(float f) { printf("%f\n", f); } bar() { foo(17.0); } This does not generate an error message(!), but gives an incorrect result (0): extern void foo(double f); void foo(f) float f; { printf("%f\n", f); } bar() { foo(17.0); } Has someone heard about a fix to this?