Paul Eggert wrote: > This is only a partial cleanup; to be cleaner we’d need to > move declarations of Gnulib extensions like c32isalpha > into a separate .h file.
I would not like such a move at all. IMO it is more important that programmers can remember which #includes to use, than the namespace cleanliness. Especially since your doc patch https://lists.gnu.org/archive/html/bug-gnulib/2026-04/msg00166.html reminds us that in many places "POSIX.1-2024 allows, but does not require, this file to make visible all symbols from ..." That is, we cannot achieve the goal that compiling a source code file would indicate to the programmer which #includes are missing. We can only approximate this goal. The choice of the .h file for gnulib functions is meant to make it easy to remember: - old character and string functions => <string.h>, <ctype.h>, - wide character functions => <wchar.h>, <wctype.h>, - 32-bit wide character functions => <uchar.h>. > * tests/test-uchar-h.c: Move a static_assert here from lib/uchar.in.h, > and include <wchar.h> so that wchar_t is guaranteed to be visible. 2026-04-25 Bruno Haible <[email protected]> uchar-h tests: Strengthen tests. * tests/test-uchar-h.c: Move #include <wchar.h> after most other tests are done. diff --git a/tests/test-uchar-h.c b/tests/test-uchar-h.c index 4b0667df58..9c054ed065 100644 --- a/tests/test-uchar-h.c +++ b/tests/test-uchar-h.c @@ -18,13 +18,9 @@ #include <config.h> +/* Specification. */ #include <uchar.h> -#include <wchar.h> - -#if _GL_WCHAR_T_IS_UCS4 -static_assert (sizeof (char32_t) == sizeof (wchar_t)); -#endif /* Check that the types are defined. */ mbstate_t a = { 0 }; @@ -49,6 +45,15 @@ static_assert ((char16_t)0xFFFF != (char16_t)0x7FFF); /* Check that char32_t is at least 31 bits wide. */ static_assert ((char32_t)0x7FFFFFFF != (char32_t)0x3FFFFFFF); + +/* Checks relating to wchar_t. */ + +#include <wchar.h> + +#if _GL_WCHAR_T_IS_UCS4 +static_assert (sizeof (char32_t) == sizeof (wchar_t)); +#endif + /* Check that _GL_SMALL_WCHAR_T is correctly defined. */ #if _GL_SMALL_WCHAR_T static_assert (sizeof (wchar_t) < sizeof (char32_t)); @@ -56,6 +61,7 @@ static_assert (sizeof (wchar_t) < sizeof (char32_t)); static_assert (sizeof (wchar_t) == sizeof (char32_t)); #endif + int main (void) {
