Paul Eggert wrote on 2026-03-16:
> diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h
> index 919e472f63..ddc7e7e4f4 100644
> --- a/lib/stdbit.in.h
> +++ b/lib/stdbit.in.h
> @@ -37,21 +37,29 @@
>   #error "Please include config.h first."
>  #endif
>  
> -#if @GNULIB_STDC_MEMREVERSE8@
> -
> +#if !@HAVE_STDBIT_H@
>  /* Get size_t.  */
>  # include <stddef.h>
> -
>  #endif
>  
> -#if @GNULIB_STDC_MEMREVERSE8U@ || @GNULIB_STDC_LOAD8_ALIGNED@ || 
> @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_STORE8_ALIGNED@ || @GNULIB_STDC_STORE8@
> -
> -/* Get uint8_t, uint16_t, uint32_t, uint64_t,
> -   int_least8_t, int_least16_t, int_least32_t, int_least64_t,
> -   uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t,
> -   uint_fast16_t, uint_fast32_t, uint_fast64_t.  */
> +#if (!@HAVE_STDBIT_H@ \
> +     || (!defined __UINT_FAST64_TYPE__ \
> +         && (@GNULIB_STDC_MEMREVERSE8U@ \
> +             || @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_LOAD8_ALIGNED@ \
> +             || @GNULIB_STDC_STORE8@ || @GNULIB_STDC_STORE8_ALIGNED@)))
> +/* Get intN_t, uintN_t, int_leastN_t, uint_leastN_t.  */
>  # include <stdint.h>
> +#endif

This part causes syntax errors, when I build a testdir of all of Gnulib
(--with-c++-tests) on Ubuntu 24.04 with gcc 15.2.0:

g++ -ftrapv -DHAVE_CONFIG_H -DEXEEXT=\"\" -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/media/develdata/devel/inst-x86_64-64/include -Wall -Wno-error -Wno-error -g 
-O2 -MT test-stdbit-h-c++.o -MD -MP -MF $depbase.Tpo -c -o test-stdbit-h-c++.o 
../../gltests/test-stdbit-h-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-stdbit-h-c++.cc:22:
../gllib/stdbit.h:1315:1: error: variable or field 'stdc_memreverse8' declared 
void
 1315 | stdc_memreverse8 (size_t n, unsigned char *ptr)
      | ^~~~~~~~~~~~~~~~
../gllib/stdbit.h:1315:19: error: 'size_t' was not declared in this scope
 1315 | stdc_memreverse8 (size_t n, unsigned char *ptr)
      |                   ^~~~~~

Once this is fixed (via <stddef.h>), a similar error occurs because of
uint_least8_t, uint_least16_t, uint_least32_t.

These regressions come from the "stdbit-h: namespace cleanup on recent GNU"
patch.

Another compilation error, due to __STDC_NATIVE_* not defined in C++ mode,
was already present before.


2026-04-28  Bruno Haible  <[email protected]>

        stdbit-h: Fix syntax error in C++ mode.
        * lib/stdbit.in.h (__STDC_ENDIAN_*): Define also in C++ mode.

2026-04-28  Bruno Haible  <[email protected]>

        stdbit-h: Fix syntax errors in C++ mode (regression 2026-03-16).
        * lib/stdbit.in.h: Include <stddef.h> also for the stdc_memreverse8
        module. Include <stdint.h> also when HAVE_STDBIT_H is 1 and
        __UINT_FAST64_TYPE__ is defined and some module needs it.

>From 949b91c071374832a4483717577c620a03812de8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Wed, 29 Apr 2026 01:23:23 +0200
Subject: [PATCH 1/2] stdbit-h: Fix syntax errors in C++ mode (regression
 2026-03-16).

* lib/stdbit.in.h: Include <stddef.h> also for the stdc_memreverse8
module. Include <stdint.h> also when HAVE_STDBIT_H is 1 and
__UINT_FAST64_TYPE__ is defined and some module needs it.
---
 ChangeLog       |  7 +++++++
 lib/stdbit.in.h | 12 ++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 869eb1e1a3..397c58072a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-04-28  Bruno Haible  <[email protected]>
+
+	stdbit-h: Fix syntax errors in C++ mode (regression 2026-03-16).
+	* lib/stdbit.in.h: Include <stddef.h> also for the stdc_memreverse8
+	module. Include <stdint.h> also when HAVE_STDBIT_H is 1 and
+	__UINT_FAST64_TYPE__ is defined and some module needs it.
+
 2026-04-28  Bruno Haible  <[email protected]>
 
 	uchar-h: Support multiple gnulib-tool invocations in the same package.
diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h
index bcc883b3de..b5ee3b3568 100644
--- a/lib/stdbit.in.h
+++ b/lib/stdbit.in.h
@@ -37,16 +37,16 @@
  #error "Please include config.h first."
 #endif
 
-#if !@HAVE_STDBIT_H@ || (defined __cplusplus && defined __INTEL_CLANG_COMPILER)
+#if (!@HAVE_STDBIT_H@ || @GNULIB_STDC_MEMREVERSE8@ \
+     || (defined __cplusplus && defined __INTEL_CLANG_COMPILER))
 /* Get size_t.  */
 # include <stddef.h>
 #endif
 
-#if (!@HAVE_STDBIT_H@ \
-     || (!defined __UINT_FAST64_TYPE__ \
-         && (@GNULIB_STDC_MEMREVERSE8U@ \
-             || @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_LOAD8_ALIGNED@ \
-             || @GNULIB_STDC_STORE8@ || @GNULIB_STDC_STORE8_ALIGNED@)) \
+#if (!(@HAVE_STDBIT_H@ && defined __UINT_FAST64_TYPE__) \
+     || @GNULIB_STDC_MEMREVERSE8U@ \
+     || @GNULIB_STDC_LOAD8@ || @GNULIB_STDC_LOAD8_ALIGNED@ \
+     || @GNULIB_STDC_STORE8@ || @GNULIB_STDC_STORE8_ALIGNED@ \
      || (defined __cplusplus && defined __INTEL_CLANG_COMPILER))
 /* Get intN_t, uintN_t, int_leastN_t, uint_leastN_t.  */
 # include <stdint.h>
-- 
2.52.0

From f4107215998a69060314ca5096e0ab1bde3241ff Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Wed, 29 Apr 2026 01:19:10 +0200
Subject: [PATCH 2/2] stdbit-h: Fix syntax error in C++ mode.

* lib/stdbit.in.h (__STDC_ENDIAN_*): Define also in C++ mode.
---
 ChangeLog       | 5 +++++
 lib/stdbit.in.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 397c58072a..7cc44b145e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2026-04-28  Bruno Haible  <[email protected]>
+
+	stdbit-h: Fix syntax error in C++ mode.
+	* lib/stdbit.in.h (__STDC_ENDIAN_*): Define also in C++ mode.
+
 2026-04-28  Bruno Haible  <[email protected]>
 
 	stdbit-h: Fix syntax errors in C++ mode (regression 2026-03-16).
diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h
index b5ee3b3568..33758c31a4 100644
--- a/lib/stdbit.in.h
+++ b/lib/stdbit.in.h
@@ -195,7 +195,7 @@ extern "C" {
 
 
 /* Some systems are only missing C2y features in stdbit.h.  */
-#if !@HAVE_STDBIT_H@ || (defined __cplusplus && defined __INTEL_CLANG_COMPILER)
+#if !@HAVE_STDBIT_H@ || defined __cplusplus
 
 /* ISO C 23 ?? 7.18.1 General  */
 
-- 
2.52.0

Reply via email to