Promoting floats to doubles?
Jim Wilson
wilson@specifixinc.com
Mon May 3 20:39:00 GMT 2004
Kean Johnston wrote:
> Is there a way I can instruct GCC to always promote floats?
In K&R C, floats are promoted to double. In ISO C, they are not.
The main difference here is prototypes. If you have an old-style
function definition, and there is no prototype in scope, then it will be
compiled with floats promoted to double. If you have a function call,
and there is no prototype in scope, or this is an unnamed stdarg
argument, then a float will be promoted to double.
If there is a prototype, and the prototype specifies float, then the
float will not be promoted to double.
It sounds like you have a prototype that disagrees with the function
definition, in which case you should fix the prototype.
There are some hooks here, TARGET_PROMOTE_FUNCTION_ARGS,
TARGET_PROMOTE_PROTOTYPES, TARGET_PROMOTE_FUNCTION_RETURN, but they are
really only useful for promoting char/short/int types. They won't work
for promoting float to double.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list