BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

problem with math functions

Highlighted
Occasional Visitor

problem with math functions

Hi.

I just installed gcc-3.3.2 on a Hp-ux 11.0, from available binaries at the HP-UX software porting and archive center.

When I try to compile, I get the folowing error:

/usr/local/include/c++/3.3.2/cmath: In function `double std::abs(double)':
/usr/local/include/c++/3.3.2/cmath:172: error: `double std::abs(double)' conflicts with previous using declaration `double abs(double)'
/usr/local/include/c++/3.3.2/cmath: In function `double std::pow(double, int)':
/usr/local/include/c++/3.3.2/cmath:504: error: `double std::pow(double, int)' conflicts with previous using declaration `double pow(double, int)'


(Edited from include/c++/3.3.2/cmath)
I changed things from:

// Get rid of those macros defined in in lieu of real functions.
#undef abs // <--- This is one I had trouble with.
#undef div
// etc...

namespace std
{
inline double
abs(double __x)
{ return __builtin_fabs(__x); }

inline float
abs(float __x)
{ return __builtin_fabsf(__x); }

inline long double
abs(long double __x)
{ return __builtin_fabsl(__x); }
}

to:

// Get rid of those macros defined in in lieu of real functions.
#undef div
// etc...

namespace std
{
// Only undefine and replace abs if it is a macro
#ifdef abs
#undef abs
inline double
abs(double __x)
{ return __builtin_fabs(__x); }

inline float
abs(float __x)
{ return __builtin_fabsf(__x); }

inline long double
abs(long double __x)
{ return __builtin_fabsl(__x); }
#endif
}

Is it correct or not?
What is the "good" way to fix it?

Thanks

Pierre Burry