Problem with float in TurboC 1.0?

Steve Harrold swh at hpcupt1.HP.COM
Tue Oct 10 02:51:11 AEST 1989


Re: floats with Turbo C

Be careful when passing "float" types with any ANSI-conformant compiler.

When you compile a function that is declared as expecting a "float" parameter,
the ANSI compiler will generate code to extract a "float" value from the stack.

If, in a separate compilation, you have a program that references the function,
AND you neglect to explicitly provide a prototype statement that declares the
"float" specification, the compiler will generate code the "old fashioned"
way and insert a "double" into the stack.  Because this parameter type
mismatch is not (generally) detected by the linker you use, the run time
execution will be unpredictable (because "double"s are placed into the stack,
but are being extracted as "single"s!!).

Hope this provides the clue you need.



More information about the Comp.lang.c mailing list