From: Bruno Haible Date: Wed, 19 Aug 2020 23:27:02 +0000 (+0200) Subject: uchar: Fix compilation errors in C++ mode on macOS. X-Git-Tag: v1.0~3701 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=6d704d3a1f65cda7c11630cd914b4bc877ddf224;p=gnulib.git uchar: Fix compilation errors in C++ mode on macOS. * m4/uchar.m4 (gl_UCHAR_H): Require gl_ANSI_CXX if present. Include some system header file before attempting to use 'char16_t' and 'char32_t'. --- diff --git a/ChangeLog b/ChangeLog index 0814926c3c..9262744808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-08-19 Bruno Haible + + uchar: Fix compilation errors in C++ mode on macOS. + * m4/uchar.m4 (gl_UCHAR_H): Require gl_ANSI_CXX if present. Include some + system header file before attempting to use 'char16_t' and 'char32_t'. + 2020-08-19 Bruno Haible ansi-c++-opt: Work around an autoconf macro reordering problem. diff --git a/m4/uchar.m4 b/m4/uchar.m4 index a573f5da1f..a17ca1545c 100644 --- a/m4/uchar.m4 +++ b/m4/uchar.m4 @@ -1,4 +1,4 @@ -# uchar.m4 serial 15 +# uchar.m4 serial 16 dnl Copyright (C) 2019-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,7 +23,10 @@ AC_DEFUN_ONCE([gl_UCHAR_H], gl_TYPE_CHAR32_T dnl In C++ mode, clang defines 'char16_t' and 'char32_t' as built-in types - dnl on some platforms (e.g. OpenBSD 6.7). + dnl on some platforms (e.g. OpenBSD 6.7), and as types defined by many + dnl header files (, , , , + dnl and others) on some platforms (e.g. Mac OS X 10.13). + m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])]) CXX_HAS_UCHAR_TYPES=0 if test $HAVE_UCHAR_H = 0; then if test "$CXX" != no; then @@ -31,7 +34,11 @@ AC_DEFUN_ONCE([gl_UCHAR_H], [gl_cv_cxx_has_uchar_types], [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to dnl an autoconf bug . - echo 'char16_t a; char32_t b;' > conftest.cpp + cat > conftest.cpp <<\EOF +#include +char16_t a; +char32_t b; +EOF gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp" if AC_TRY_EVAL([gl_command]); then gl_cv_cxx_has_uchar_types=yes