This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
implementation of c++ overloaded standard math functions
- To: gcc at gcc dot gnu dot org
- Subject: implementation of c++ overloaded standard math functions
- From: Theodore Todorov <todorov at mail dot cern dot ch>
- Date: Mon, 8 Nov 1999 15:43:08 +0100 (MET)
- cc: Alexandre Khanov <Alexandre dot Khanov at cern dot ch>
Hello,
In ISO/ANSI C++ the math functions from math.h that take
a double as argument (like sqrt) are overloaded to also take
a float as an argument [26.5.6 "C Library"]
In g++ <cmath> there is a section with the new prototypes, but it is
effectively commented out by an "#if 0" :
#include <math.h>
#ifdef __GNUG__
#pragma interface "cmath"
#endif
extern "C++" {
#if 0
float acos (float);
[..... all other functions from math.h .....]
On the other hand, math.h defines both double and float versions of
these functions, and adds a "f" suffix to the names of the float
versions, i.e. we have access to
float sqtrf (float); //gcc extension?
^
double sqrt (double); //standard C
My question is, why not define the standard C++ float functions
via the corresponding "f"-suffixed functions, e.g.
float sqtr (float f) { return sqrtf( f);}
instead of commenting them out of the <cmath> header?
Best regards,
Teddy (Theodore.Todorov@cern.ch)