This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

implementation of c++ overloaded standard math functions


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)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]