From 4c0760d327e390a37d0d6ce2016d3a8c5b87a119 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 30 Nov 2016 15:29:45 -0800 Subject: Re-fix the build with ICC and cmath & math.h Commit c35fef9d3b8bb77a7f303e3cd62c86cd00e57f5b wasn't sufficient. The problem is that there's a complex combination of libc headers (math.h), C++ headers (cmath), which may be provided by three different sources on Linux (glibc, gcc and ICC). On some combinations, the isnan macro leaks from math.h or cmath and that's what the the commit above tried to fix. On some other combinations, there's no macro but there's an ::isnan function defined. When we do "using namespace std; return isnan(x);", that causes a compilation error. This commit solves that by detecting whether there is a macro defined. error: more than one instance of overloaded function "isnan" matches the argument list function "isnan(double)" function "std::isnan(double)" argument types are: (double) Change-Id: Iaeecaffe26af4535b416fffd148bf71826541bdd Reviewed-by: Thiago Macieira --- src/corelib/global/qnumeric_p.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 23fcf340f1..01b8772ee1 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -68,7 +68,8 @@ #if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || defined(Q_CC_INTEL) || !defined(__cplusplus)) # include -# define QT_MATH_H_DEFINES_MACROS +# ifdef isnan +# define QT_MATH_H_DEFINES_MACROS QT_BEGIN_NAMESPACE namespace qnumeric_std_wrapper { // the 'using namespace std' below is cases where the stdlib already put the math.h functions in the std namespace and undefined the macros. @@ -81,10 +82,11 @@ static inline bool math_h_isfinite(float f) { using namespace std; return isfini } QT_END_NAMESPACE // These macros from math.h conflict with the real functions in the std namespace. -#undef signbit -#undef isnan -#undef isinf -#undef isfinite +# undef signbit +# undef isnan +# undef isinf +# undef isfinite +# endif // defined(isnan) #endif QT_BEGIN_NAMESPACE -- cgit v1.2.3