* lib/stdbit.in.h: Include <stddef.h> only if the stdc_memreverse8
module is also used, since it’s the only one that needs size_t.
Define __need_size_t before including <stddef.h>, so that <stddef.h>
defines only size_t on GNU platforms.
---
 ChangeLog       | 6 ++++++
 lib/stdbit.in.h | 8 +++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6033ba8259..86585c6ff6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2026-04-29  Paul Eggert  <[email protected]>
 
+       stdbit-h: <stddef.h> namespace cleanup
+       * lib/stdbit.in.h: Include <stddef.h> only if the stdc_memreverse8
+       module is also used, since it’s the only one that needs size_t.
+       Define __need_size_t before including <stddef.h>, so that <stddef.h>
+       defines only size_t on GNU platforms.
+
        stdbit-h: include <stdint.h> only on module req
        This is another attempt to tighten up the <stdbit.h> namespace
        on GNU platforms, and follows up on previous C++ fixes here.
diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h
index 6be873260a..04a9dfd183 100644
--- a/lib/stdbit.in.h
+++ b/lib/stdbit.in.h
@@ -37,9 +37,11 @@
  #error "Please include config.h first."
 #endif
 
-#if (!@HAVE_STDBIT_H@ || @GNULIB_STDC_MEMREVERSE8@ \
-     || (defined __cplusplus && defined __INTEL_CLANG_COMPILER))
-/* Get size_t.  */
+/* If needed for APIs, get size_t, avoiding namespace pollution on GNU.  */
+#if (@GNULIB_STDC_MEMREVERSE8@ \
+     && (!@HAVE_STDBIT_H@ \
+         || (defined __cplusplus && defined __INTEL_CLANG_COMPILER)))
+# define __need_size_t
 # include <stddef.h>
 #endif
 
-- 
2.54.0


Reply via email to