This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Promoting floats to doubles?
- From: Jim Wilson <wilson at specifixinc dot com>
- To: Kean Johnston <jkj at sco dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 03 May 2004 13:39:48 -0700
- Subject: Re: Promoting floats to doubles?
- References: <409493B7.6040108@sco.com>
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