+2025-09-01 Bruno Haible <bruno@clisp.org>
+
+ uchar-h: Fix compilation error of <cuchar> in C++ mode on macOS 15.
+ * lib/uchar.in.h: In C++ mode, use CXX_HAVE_UCHAR_H instead of
+ HAVE_UCHAR_H.
+ * m4/uchar_h.m4 (gl_UCHAR_H): Set CXX_HAVE_UCHAR_H.
+ * modules/uchar-h (Makefile.am): Substitute CXX_HAVE_UCHAR_H.
+
2025-09-01 Collin Funk <collin.funk1@gmail.com>
sys_types-h tests: Fix a static_assert failure on glibc/alpha.
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
-#if @HAVE_UCHAR_H@
+#if (defined __cplusplus ? @CXX_HAVE_UCHAR_H@ : @HAVE_UCHAR_H@)
# if defined __HAIKU__
/* Work around <https://dev.haiku-os.org/ticket/17040>. */
# include <stdint.h>
_GL_INLINE_HEADER_BEGIN
-#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_CHAR8_TYPE@))
+#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_CHAR8_TYPE@ : @HAVE_UCHAR_H@)
/* An 8-bit variant of wchar_t.
Note: This type is only mandated by ISO C 23 or newer, and it does
#endif
-#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
+#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
/* A 16-bit variant of wchar_t.
Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
#endif
-#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
+#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
/* A 32-bit variant of wchar_t.
Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
# uchar_h.m4
-# serial 31
+# serial 32
dnl Copyright (C) 2019-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
fi
AC_SUBST([HAVE_UCHAR_H])
+ dnl On macOS 15, in C mode, <uchar.h> does not exist. But in C++ mode,
+ dnl it exists, and we need to #include_next it, otherwise we get an error
+ dnl "<cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h>
+ dnl header."
+ m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
+ CXX_HAVE_UCHAR_H=0
+ if test "$CXX" != no; then
+ AC_CACHE_CHECK([whether the C++ compiler has <uchar.h>],
+ [gl_cv_cxx_have_uchar_h],
+ [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
+ dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
+ cat > conftest.cpp <<\EOF
+#include <uchar.h>
+EOF
+ gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
+ if AC_TRY_EVAL([gl_command]); then
+ gl_cv_cxx_have_uchar_h=yes
+ else
+ gl_cv_cxx_have_uchar_h=no
+ fi
+ rm -fr conftest*
+ ])
+ if test $gl_cv_cxx_have_uchar_h = yes; then
+ CXX_HAVE_UCHAR_H=1
+ fi
+ fi
+ AC_SUBST([CXX_HAVE_UCHAR_H])
+
gl_TYPE_CHAR8_T
gl_TYPE_CHAR16_T
gl_TYPE_CHAR32_T
CXX_HAS_CHAR8_TYPE=0
if test $HAVE_UCHAR_H = 0; then
if test "$CXX" != no; then
- AC_CACHE_CHECK([whether the C++ compiler predefines the char8_t types],
+ AC_CACHE_CHECK([whether the C++ compiler predefines the char8_t type],
[gl_cv_cxx_has_char8_type],
[dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
$(gl_V_at)$(SED_HEADER_STDOUT) \
-e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
-e 's/@''HAVE_UCHAR_H''@/$(HAVE_UCHAR_H)/g' \
+ -e 's/@''CXX_HAVE_UCHAR_H''@/$(CXX_HAVE_UCHAR_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \