This is another attempt to tighten up the <stdbit.h> namespace on GNU platforms, and follows up on previous C++ fixes here. * lib/stdbit.in.h: Include <stdint.h> only when also using a module like stdc_memreverse8 with an API that uses <stdint.h> types that are not otherwise defined. This should work better with portable code, as code that merely wants u?int(_least)?N_t should include <stdint.h>, not <stdbit.h>. (_GL_STDBIT_UINT_FAST16 _GL_STDBIT_UINT_FAST32) (_GL_STDBIT_UINT_FAST64): Simplify logic by defining them to the <stdint.h> equivalents whenever stdint.h is included. --- ChangeLog | 14 ++++++++++++++ lib/stdbit.in.h | 33 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 824928bc39..6033ba8259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2026-04-29 Paul Eggert <[email protected]> + + 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. + * lib/stdbit.in.h: Include <stdint.h> only when also using a + module like stdc_memreverse8 with an API that uses <stdint.h> + types that are not otherwise defined. + This should work better with portable code, as code that merely + wants u?int(_least)?N_t should include <stdint.h>, not <stdbit.h>. + (_GL_STDBIT_UINT_FAST16 _GL_STDBIT_UINT_FAST32) + (_GL_STDBIT_UINT_FAST64): Simplify logic by defining them to the + <stdint.h> equivalents whenever stdint.h is included. + 2026-04-29 Bruno Haible <[email protected]> mbrtoc32-regular: Strengthen the configure test. diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index d6fb854a57..6be873260a 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -43,24 +43,23 @@ # include <stddef.h> #endif -#if (!(@HAVE_STDBIT_H@ && defined __UINT_FAST64_TYPE__) \ - || @GNULIB_STDC_MEMREVERSE8U@ \ +/* If needed for APIs, get intN_t, uintN_t, int_leastN_t, + uint_leastN_t, and (for internal use) get equivalents of + uint_fast{16,32,64}_t. Avoid namespace pollution on GNU. */ +#if (@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> -#endif - -/* uint_fast{16,32,64}_t equivalents, sans namespace pollution on GNU. */ -#if @HAVE_STDBIT_H@ && defined __UINT_FAST64_TYPE__ -# define _GL_STDBIT_UINT_FAST16 __UINT_FAST16_TYPE__ -# define _GL_STDBIT_UINT_FAST32 __UINT_FAST32_TYPE__ -# define _GL_STDBIT_UINT_FAST64 __UINT_FAST64_TYPE__ -#else -# define _GL_STDBIT_UINT_FAST16 uint_fast16_t -# define _GL_STDBIT_UINT_FAST32 uint_fast32_t -# define _GL_STDBIT_UINT_FAST64 uint_fast64_t + || @GNULIB_STDC_STORE8@ || @GNULIB_STDC_STORE8_ALIGNED@) +# if (!(@HAVE_STDBIT_H@ && defined __UINT_FAST64_TYPE__) \ + || (defined __cplusplus && defined __INTEL_CLANG_COMPILER)) +# include <stdint.h> +# define _GL_STDBIT_UINT_FAST16 uint_fast16_t +# define _GL_STDBIT_UINT_FAST32 uint_fast32_t +# define _GL_STDBIT_UINT_FAST64 uint_fast64_t +# else +# define _GL_STDBIT_UINT_FAST16 __UINT_FAST16_TYPE__ +# define _GL_STDBIT_UINT_FAST32 __UINT_FAST32_TYPE__ +# define _GL_STDBIT_UINT_FAST64 __UINT_FAST64_TYPE__ +# endif #endif #if @GNULIB_STDC_MEMREVERSE8U@ || @GNULIB_STDC_LOAD8_ALIGNED@ || @GNULIB_STDC_STORE8_ALIGNED@ -- 2.54.0
