Paul Eggert wrote:
> Use __has_include to detect this; that should be good enough nowadays.
While it is an interesting experiment to use __has_include instead of
AC_CHECK_HEADERS, it has two drawbacks:
- It does not work with all C compilers, in particular
AIX xlc, Sun C, TinyC.
- It does not guard against header files with syntax errors.
The latter drawback is actually a problem here. We are documenting
this portability problem of <uchar.h>:
@item
This file is not self-contained on some platforms:
@c https://dev.haiku-os.org/ticket/17040
Haiku.
And indeed, on Haiku of 2022, there is a compilation error:
gcc -DHAVE_CONFIG_H -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1
-I/boot/home/config/non-packaged/include -Wall -g -O2 -MT propername-lite.o
-MD -MP -MF .deps/propername-lite.Tpo -c -o propername-lite.o
../../gllib/propername-lite.c
In file included from ../../gllib/propername-lite.c:26:
/boot/system/develop/headers/posix/uchar.h:17:9: error: unknown type name
'uint_least32_t'
17 | typedef uint_least32_t char32_t;
| ^~~~~~~~~~~~~~
/boot/system/develop/headers/posix/uchar.h:18:9: error: unknown type name
'uint_least16_t'
18 | typedef uint_least16_t char16_t;
| ^~~~~~~~~~~~~~
Makefile:1095: recipe for target 'propername-lite.o' failed
make[4]: *** [propername-lite.o] Error 1
This patch fixes it.
2025-09-05 Bruno Haible <[email protected]>
propername-lite: Fix compilation error on Haiku r1/beta4 (regr. today).
* lib/propername-lite.c: Test HAVE_UCHAR_H instead of relying on
__has_include.
* modules/propername-lite (Depends-on): Add uchar-h.
diff --git a/lib/propername-lite.c b/lib/propername-lite.c
index f11c9746d2..4bcb860303 100644
--- a/lib/propername-lite.c
+++ b/lib/propername-lite.c
@@ -21,17 +21,15 @@
#include "gettext.h"
-#ifdef __has_include
-# if __has_include (<uchar.h>)
-# include <uchar.h>
+#if HAVE_UCHAR_H
+# include <uchar.h>
/* There is no need for the dependency hassle of replacing glibc mbrtoc32,
as we don't care whether the C locale treats a byte with the high
bit set as an encoding error. */
-# ifdef __GLIBC__
-# undef mbrtoc32
-# endif
-# define USE_MBRTOC32
+# ifdef __GLIBC__
+# undef mbrtoc32
# endif
+# define USE_MBRTOC32
#endif
/* Return the localization of the name spelled NAME_ASCII in ASCII,
diff --git a/modules/propername-lite b/modules/propername-lite
index 2b002debb1..20a0bfcb59 100644
--- a/modules/propername-lite
+++ b/modules/propername-lite
@@ -7,6 +7,7 @@ lib/propername.h
Depends-on:
gettext-h
+uchar-h
configure.ac:
m4_ifdef([AM_XGETTEXT_OPTION],