bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix compilation errors in C++ mode on macOS and FreeBSD


From: Bruno Haible
Subject: fix compilation errors in C++ mode on macOS and FreeBSD
Date: Sun, 08 Dec 2019 13:04:55 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

On macOS 10.13, with a testdir built with --with-c++-tests, I'm seeing these
errors:

depbase=`echo test-math-c++2.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
        g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/Users/haible/include 
-Wall   -MT test-math-c++2.o -MD -MP -MF $depbase.Tpo -c -o test-math-c++2.o 
../../gltests/test-math-c++2.cc &&\
        mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-math-c++2.cc:20:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:7:
 error: no member named
      'rpl_signbit' in the global namespace; did you mean 'gnulib::rpl_signbit'?
using ::signbit;
      ^~
../gllib/math.h:2979:45: note: 'gnulib::rpl_signbit' declared here
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
                                            ^
In file included from ../../gltests/test-math-c++2.cc:20:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:7:
 error: no member named
      'rpl_isfinite' in the global namespace; did you mean 
'gnulib::rpl_isfinite'?
using ::isfinite;
      ^~
../gllib/math.h:2737:46: note: 'gnulib::rpl_isfinite' declared here
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
                                             ^
In file included from ../../gltests/test-math-c++2.cc:20:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:7:
 error: no member named
      'rpl_isinf' in the global namespace; did you mean 'gnulib::rpl_isinf'?
using ::isinf;
      ^~
../gllib/math.h:2771:43: note: 'gnulib::rpl_isinf' declared here
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool)
                                          ^
In file included from ../../gltests/test-math-c++2.cc:20:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9:
 error: no member named
      'rpl_isnan' in the global namespace
using ::isnan;
      ~~^
../gllib/math.h:2897:19: note: expanded from macro 'isnan'
#    define isnan rpl_isnan
                  ^
4 errors generated.
make[4]: *** [test-math-c++2.o] Error 1

Likewise on FreeBSD 12.


This patch fixes it, in the same way as it was done for AIX recently
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00017.html>.


2019-12-08  Bruno Haible  <address@hidden>

        Fix compilation errors in C++ mode on macOS and FreeBSD.
        * lib/math.in.h (isfinite, isinf, isnan, signbit): In C++ mode on macOS
        or FreeBSD with clang, use the approach without C preprocessor macro.

diff --git a/lib/math.in.h b/lib/math.in.h
index 3bb9663..55130ab 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -2257,7 +2257,7 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
 #  if defined isfinite || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
 #   undef isfinite
-#   if __GNUC__ >= 6 || (defined __clang__ && !defined _AIX)
+#   if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined 
__MACH__) || defined __FreeBSD__ || defined _AIX))
   /* This platform's <cmath> possibly defines isfinite through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
@@ -2291,7 +2291,7 @@ _GL_EXTERN_C int gl_isinfl (long double x);
 #  if defined isinf || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
 #   undef isinf
-#   if __GNUC__ >= 6 || defined __clang__
+#   if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined 
__MACH__) || defined __FreeBSD__))
   /* This platform's <cmath> possibly defines isinf through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool)
@@ -2416,7 +2416,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) 
_GL_ATTRIBUTE_CONST;
 #  if defined isnan || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
 #   undef isnan
-#   if __GNUC__ >= 6 || defined __clang__
+#   if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined 
__MACH__) || defined __FreeBSD__))
   /* This platform's <cmath> possibly defines isnan through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
@@ -2499,7 +2499,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
 #  if defined signbit || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
 #   undef signbit
-#   if __GNUC__ >= 6 || (defined __clang__ && !defined _AIX)
+#   if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined 
__MACH__) || defined __FreeBSD__ || defined _AIX))
   /* This platform's <cmath> possibly defines signbit through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]