C++ problems with clang-cl in math.h
Add Reply
Gisle Vanem
2017-11-02 14:10:41 UTC
Raw Message
Hello list.

I'm trying to use Gnulib's <math.h> from clang-cl C++
compiler. I have no problems with pure C with either clang-cl
or MSVC. But in C++ I get endless troubles with errors like these:

f:/MingW32/src/gnu/gnulib/lib\math.h(2397,36): error: functions that
differ only in their return type cannot be overloaded

Thanks to the excellent 'clang-format' program, I was able to generate
this preprocessed output:

// from MSVC and UCRT's <corecrt_math.h>:

inline bool signbit(float _X) throw()
return _fdsign(_X) != 0;
inline bool signbit(double _X) throw()
return _dsign(_X) != 0;
inline bool signbit(long double _X) throw()
return _ldsign(_X) != 0;

// and then from Gnulib's <math.h>:

inline int signbit(float f)
return _gl_cxx_signbitf(f);
inline int signbit(double d)
return _gl_cxx_signbitd(d);
inline int signbit(long double l)
return _gl_cxx_signbitl(l);

I'm getting these error even without a 'REPLACE_SIGNBIT=1'.
And I fail to see how to prevent the above from getting into

I'm not C++ export, but would imagine that 'int' and 'bool'
are different types. Or does the 'throw()' have anything to do with
this error? Any hints please?

PS. I've tried clang-cl v3.9.0 and 5.0.0 with the same result.