]> Savannah Git Hosting - gnulib.git/commitdiff
uchar C++ tests: Fix build error on FreeBSD 12.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Aug 2020 08:39:03 +0000 (10:39 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 17 Aug 2020 08:46:53 +0000 (10:46 +0200)
* modules/uchar-c++-tests (configure.ac): Test whether <cuchar> exists.
(Makefile.am): Don't include test-uchar-c++2.cc in the compilation if
<cuchar> does not exist.

ChangeLog
modules/uchar-c++-tests

index 8d72748ba1dddd2af9e3e6440e66d199a5426c67..6a053a2cca64f2d4cc474ef400b16fb6253dc8a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-08-17  Bruno Haible  <bruno@clisp.org>
+
+       uchar C++ tests: Fix build error on FreeBSD 12.
+       * modules/uchar-c++-tests (configure.ac): Test whether <cuchar> exists.
+       (Makefile.am): Don't include test-uchar-c++2.cc in the compilation if
+       <cuchar> does not exist.
+
 2020-08-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        time_rz: remove unused functions
index 4f179f05a0c5f6f6d6d3add7573b473164fc4c79..2cbc3312b52a95e6748b1b4e3f1cdea3084ee2b0 100644 (file)
@@ -10,11 +10,34 @@ Depends-on:
 ansi-c++-opt
 
 configure.ac:
+AC_REQUIRE([gl_ANSI_CXX])
+if test "$CXX" != no; then
+  dnl On FreeBSD 12, 'c++' defines __cplusplus to 201402, although it does not
+  dnl have the <cuchar> header file from C++11.
+  AC_CACHE_CHECK([whether the C++ compiler has <cuchar>],
+    [gl_cv_cxxheader_cuchar],
+    [AC_LANG_PUSH([C++])
+     AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <cuchar>]],
+          [[]])
+       ],
+       [gl_cv_cxxheader_cuchar=yes],
+       [gl_cv_cxxheader_cuchar=no])
+     AC_LANG_POP([C++])
+    ])
+else
+  gl_cv_cxxheader_cuchar=no
+fi
+AM_CONDITIONAL([CXX_HAVE_CUCHAR], [test $gl_cv_cxxheader_cuchar != no])
 
 Makefile.am:
 if ANSICXX
 TESTS += test-uchar-c++
 check_PROGRAMS += test-uchar-c++
-test_uchar_c___SOURCES = test-uchar-c++.cc test-uchar-c++2.cc
+test_uchar_c___SOURCES = test-uchar-c++.cc
+if CXX_HAVE_CUCHAR
+test_uchar_c___SOURCES += test-uchar-c++2.cc
+endif
 test_uchar_c___LDADD = $(LDADD) $(LIB_MBRTOWC)
 endif