bug-gnulib
[Top][All Lists]
Advanced

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

Re: fix compilation errors in C++ mode on Solaris 10 and Solaris 11


From: Bruno Haible
Subject: Re: fix compilation errors in C++ mode on Solaris 10 and Solaris 11
Date: Sat, 07 Dec 2019 15:16:28 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

The new C++ stdbool.h test shows a compilation error on Solaris 10 with
CC=cc, CXX=CC:

gmake[4]: Entering directory '/home/haible/testdir1/build-x86-64-cc/gltests'
source='../../gltests/test-stdbool-c++.cc' object='test-stdbool-c++.o' 
libtool=no \
DEPDIR=.deps depmode=none /bin/bash ../../build-aux/depcomp \
CC -xarch=generic64 -O -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/home/haible/prefix-x86_64/include -D_REENTRANT   -c -o test-stdbool-c++.o 
../../gltests/test-stdbool-c++.cc
"/usr/include/stdbool.h", line 42: Error: #error "Use of<stdbool.h> is valid 
only in a c99 compilation environment.".
gmake[4]: *** [Makefile:9878: test-stdbool-c++.o] Error 1

This patch fixes it.


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

        Fix compilation errors in C++ mode on Solaris 10.
        * m4/stdbool.m4 (AM_STDBOOL_H): Require AC_CANONICAL_HOST. Set STDBOOL_H
        to non-empty on Solaris with a non-GCC compiler.
        * doc/posix-headers/stdbool.texi: Mention the Solaris issue.

diff --git a/doc/posix-headers/stdbool.texi b/doc/posix-headers/stdbool.texi
index 5a2ff6a..5b7ed07 100644
--- a/doc/posix-headers/stdbool.texi
+++ b/doc/posix-headers/stdbool.texi
@@ -11,6 +11,9 @@ Portability problems fixed by Gnulib:
 This header file is missing on some platforms:
 AIX 5.1, HP-UX 11, IRIX 6.5.
 @item
+This header file is not usable in C++ mode with the vendor compiler
+on Solaris 10.
+@item
 Some compilers have bugs relating to @samp{bool}.
 @item
 This header file defines @code{true} incorrectly on some platforms:
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
index acb8522..b470b05 100644
--- a/m4/stdbool.m4
+++ b/m4/stdbool.m4
@@ -5,18 +5,32 @@ dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-#serial 7
+#serial 8
 
 # Prepare for substituting <stdbool.h> if it is not supported.
 
 AC_DEFUN([AM_STDBOOL_H],
 [
   AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
+  AC_REQUIRE([AC_CANONICAL_HOST])
 
-  # Define two additional variables used in the Makefile substitution.
-
+  dnl On some platforms, <stdbool.h> does not exist or does not conform to C99.
+  dnl On Solaris 10 with CC=cc CXX=CC, <stdbool.h> exists but is not usable
+  dnl in C++ mode (and no <cstdbool> exists). In this case, we use our
+  dnl replacement, also in C mode (for binary compatibility between C and C++).
   if test "$ac_cv_header_stdbool_h" = yes; then
-    STDBOOL_H=''
+    case "$host_os" in
+      solaris*)
+        if test -z "$GCC"; then
+          STDBOOL_H='stdbool.h'
+        else
+          STDBOOL_H=''
+        fi
+        ;;
+      *)
+        STDBOOL_H=''
+        ;;
+    esac
   else
     STDBOOL_H='stdbool.h'
   fi




reply via email to

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