From: Paul Eggert Date: Thu, 30 Apr 2026 00:10:56 +0000 (-0700) Subject: stdbit-h: namespace cleanup port to G++ 15 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;ds=inline;p=thirdparty%2Fgnulib.git stdbit-h: namespace cleanup port to G++ 15 For the namespace cleanup, don’t assume that the system defines size_t etc. unless it also defines __STDC_VERSION_STDBIT_H__. This works around problems with C++ compilers where ‘#include ’ is a no-op, such as g++ 15.2.1. Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2026-04/msg00203.html It also lets us simplify the code by removing a special case for the Intel icpx C++ compiler. * lib/stdbit.in.h: When deciding whether works, use (defined __STDC_VERSION_STDBIT_H__) rather than @HAVE_STDBIT_H@. This fixes problems when works for C so @HAVE_STDBIT_H@ is 1, whereas does nothing for C++. (__STDC_VERSION_STDBIT_H__): Move definition to end. --- diff --git a/ChangeLog b/ChangeLog index 86585c6ff6..98aff8ecd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2026-04-29 Paul Eggert + stdbit-h: namespace cleanup port to G++ 15 + For the namespace cleanup, don’t assume that the system + defines size_t etc. unless it also defines + __STDC_VERSION_STDBIT_H__. This works around problems with C++ + compilers where ‘#include ’ is a no-op, such as g++ 15.2.1. + Problem reported by Bruno Haible in: + https://lists.gnu.org/r/bug-gnulib/2026-04/msg00203.html + It also lets us simplify the code by removing a special case for + the Intel icpx C++ compiler. + * lib/stdbit.in.h: When deciding whether works, + use (defined __STDC_VERSION_STDBIT_H__) rather than @HAVE_STDBIT_H@. + This fixes problems when works for C so @HAVE_STDBIT_H@ + is 1, whereas does nothing for C++. + (__STDC_VERSION_STDBIT_H__): Move definition to end. + stdbit-h: namespace cleanup * lib/stdbit.in.h: Include only if the stdc_memreverse8 module is also used, since it’s the only one that needs size_t. diff --git a/doc/posix-headers/stdbit.texi b/doc/posix-headers/stdbit.texi index 87f91d0a54..b658447021 100644 --- a/doc/posix-headers/stdbit.texi +++ b/doc/posix-headers/stdbit.texi @@ -15,6 +15,9 @@ Portability problems fixed by Gnulib: This header file is missing on many non-C23 platforms: glibc 2.38, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @item +This header file exists but is a no-op: +G++ 15.2. +@item This header file does not define the necessary types with the Intel @code{icpx} C++ compiler. @end itemize diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index 04a9dfd183..990f3edfde 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -38,9 +38,7 @@ #endif /* 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))) +#if @GNULIB_STDC_MEMREVERSE8@ && !defined __STDC_VERSION_STDBIT_H__ # define __need_size_t # include #endif @@ -51,8 +49,7 @@ #if (@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__) \ - || (defined __cplusplus && defined __INTEL_CLANG_COMPILER)) +# if !(defined __STDC_VERSION_STDBIT_H__ && defined __UINT_FAST64_TYPE__) # include # define _GL_STDBIT_UINT_FAST16 uint_fast16_t # define _GL_STDBIT_UINT_FAST32 uint_fast32_t @@ -196,12 +193,7 @@ extern "C" { /* Some systems are only missing C2y features in stdbit.h. */ -#if !@HAVE_STDBIT_H@ || defined __cplusplus - -/* ISO C 23 § 7.18.1 General */ - -#define __STDC_VERSION_STDBIT_H__ 202311L - +#ifndef __STDC_VERSION_STDBIT_H__ /* ISO C 23 § 7.18.2 Endian */ @@ -217,7 +209,7 @@ extern "C" { /* Some systems are only missing C2y features in stdbit.h. */ -#if !@HAVE_STDBIT_H@ +#ifndef __STDC_VERSION_STDBIT_H__ /* ISO C 23 § 7.18.3 Count Leading Zeros */ @@ -1263,7 +1255,7 @@ stdc_bit_ceil_ull (unsigned long long int n) #endif -#endif /* @HAVE_STDBIT_H@ */ +#endif /* !__STDC_VERSION_STDBIT_H__ */ /* ISO C2y § 7.18.17 Rotate Left */ @@ -2212,5 +2204,10 @@ stdc_store8_aligned_les64 (int_least64_t value, unsigned char ptr[8]) _GL_INLINE_HEADER_END +/* ISO C 23 § 7.18.1 General */ +#ifndef __STDC_VERSION_STDBIT_H__ +# define __STDC_VERSION_STDBIT_H__ 202311L +#endif + #endif /* _@GUARD_PREFIX@_STDBIT_H */ #endif /* _@GUARD_PREFIX@_STDBIT_H */