bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

uchar: Work around Haiku bug


From: Bruno Haible
Subject: uchar: Work around Haiku bug
Date: Wed, 05 Apr 2023 14:46:02 +0200

On Haiku (2021 / 2022), <uchar.h> is not self-contained:

/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;
      |         ^~~~~~~~~~~~~~

Reported at <https://dev.haiku-os.org/ticket/17040>.

This patch adds a workaround.


2023-04-05  Bruno Haible  <bruno@clisp.org>

        uchar: Work around Haiku bug.
        * m4/uchar_h.m4 (gl_UCHAR_H, gl_TYPE_CHAR8_T, gl_TYPE_CHAR16_T,
        gl_TYPE_CHAR32_T): Before including <uchar.h>, on Haiku, first include
        <stdint.h>.
        * m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Likewise.
        * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32, gl_CHECK_FUNC_MBRTOC32,
        gl_MBRTOC32_EMPTY_INPUT, gl_MBRTOC32_C_LOCALE, gl_MBRTOC32_SANITYCHECK):
        Likewise.
        * lib/uchar.in.h: On Haiku, include <stdint.h> before the include_next.
        * doc/posix-headers/uchar.texi: Mention the Haiku bug.

diff --git a/doc/posix-headers/uchar.texi b/doc/posix-headers/uchar.texi
index 945ce665fd..64c8e3a8d7 100644
--- a/doc/posix-headers/uchar.texi
+++ b/doc/posix-headers/uchar.texi
@@ -13,6 +13,10 @@ Portability problems fixed by Gnulib:
 This header file is missing on many non-glibc platforms:
 glibc 2.15, macOS 11.1, FreeBSD 6.4, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 
7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin, mingw, MSVC 9.
 @item
+This file is not self-contained on some platforms:
+@c https://dev.haiku-os.org/ticket/17040
+Haiku.
+@item
 This file produces compilation errors in C++ mode on some platforms:
 AIX 7.2 with xlclang++.
 @end itemize
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index bd1c5441cc..7c20ddd878 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -28,6 +28,10 @@
 @PRAGMA_COLUMNS@
 
 #if @HAVE_UCHAR_H@
+# if defined __HAIKU__
+/* Work around <https://dev.haiku-os.org/ticket/17040>.  */
+#  include <stdint.h>
+# endif
 /* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
    because it contains typedef definitions of char16_t and char32_t, however
    char16_t and char32_t are keywords in this situation.  To work around it,
diff --git a/m4/c32rtomb.m4 b/m4/c32rtomb.m4
index 539e4f884c..5073865d48 100644
--- a/m4/c32rtomb.m4
+++ b/m4/c32rtomb.m4
@@ -1,4 +1,4 @@
-# c32rtomb.m4 serial 5
+# c32rtomb.m4 serial 6
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,7 +11,12 @@ AC_DEFUN([gl_FUNC_C32RTOMB],
   AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
 
   dnl Cf. gl_CHECK_FUNCS_ANDROID
-  AC_CHECK_DECL([c32rtomb], , , [[#include <uchar.h>]])
+  AC_CHECK_DECL([c32rtomb], , ,
+    [[#ifdef __HAIKU__
+       #include <stdint.h>
+      #endif
+      #include <uchar.h>
+    ]])
   if test $ac_cv_have_decl_c32rtomb = yes; then
     dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a
     dnl static inline function on Haiku 2020.
@@ -19,6 +24,9 @@ AC_DEFUN([gl_FUNC_C32RTOMB],
       [AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <stdlib.h>
+              #ifdef __HAIKU__
+               #include <stdint.h>
+              #endif
               #include <uchar.h>
             ]],
             [[char buf[8];
@@ -54,6 +62,9 @@ changequote([,])dnl
         AC_RUN_IFELSE(
           [AC_LANG_SOURCE([[
 #include <stddef.h>
+#ifdef __HAIKU__
+ #include <stdint.h>
+#endif
 #include <uchar.h>
 int main ()
 {
diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4
index d6401fe2e4..acbd7f537c 100644
--- a/m4/mbrtoc32.m4
+++ b/m4/mbrtoc32.m4
@@ -1,4 +1,4 @@
-# mbrtoc32.m4 serial 11
+# mbrtoc32.m4 serial 12
 dnl Copyright (C) 2014-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -47,7 +47,12 @@ AC_DEFUN([gl_FUNC_MBRTOC32],
 AC_DEFUN([gl_CHECK_FUNC_MBRTOC32],
 [
   dnl Cf. gl_CHECK_FUNCS_ANDROID
-  AC_CHECK_DECL([mbrtoc32], , , [[#include <uchar.h>]])
+  AC_CHECK_DECL([mbrtoc32], , ,
+    [[#ifdef __HAIKU__
+       #include <stdint.h>
+      #endif
+      #include <uchar.h>
+    ]])
   if test $ac_cv_have_decl_mbrtoc32 = yes; then
     dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a
     dnl static inline function on Haiku 2020.
@@ -55,6 +60,9 @@ AC_DEFUN([gl_CHECK_FUNC_MBRTOC32],
       [AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <stdlib.h>
+              #ifdef __HAIKU__
+               #include <stdint.h>
+              #endif
               #include <uchar.h>
             ]],
             [[char32_t c;
@@ -87,6 +95,9 @@ changequote(,)dnl
 changequote([,])dnl
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
+           #ifdef __HAIKU__
+            #include <stdint.h>
+           #endif
            #include <uchar.h>
            static char32_t wc;
            static mbstate_t mbs;
@@ -120,6 +131,9 @@ AC_DEFUN([gl_MBRTOC32_C_LOCALE],
        [AC_LANG_PROGRAM(
           [[#include <limits.h>
             #include <locale.h>
+            #ifdef __HAIKU__
+             #include <stdint.h>
+            #endif
             #include <uchar.h>
           ]], [[
             int i;
@@ -185,6 +199,9 @@ changequote([,])dnl
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
+#ifdef __HAIKU__
+ #include <stdint.h>
+#endif
 #include <uchar.h>
 int main ()
 {
diff --git a/m4/uchar_h.m4 b/m4/uchar_h.m4
index 6df3056b32..3af24cf3e4 100644
--- a/m4/uchar_h.m4
+++ b/m4/uchar_h.m4
@@ -1,4 +1,4 @@
-# uchar_h.m4 serial 21
+# uchar_h.m4 serial 22
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -94,7 +94,11 @@ EOF
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use, and which is not
   dnl guaranteed by C11.
-  gl_WARN_ON_USE_PREPARE([[#include <uchar.h>
+  gl_WARN_ON_USE_PREPARE([[
+      #ifdef __HAIKU__
+       #include <stdint.h>
+      #endif
+      #include <uchar.h>
     ]], [c32rtomb mbrtoc32])
 ])
 
@@ -105,6 +109,9 @@ AC_DEFUN_ONCE([gl_TYPE_CHAR8_T],
     [gl_cv_type_char8_t_works],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([[
+          #ifdef __HAIKU__
+           #include <stdint.h>
+          #endif
           #include <uchar.h>
           int verify[(char8_t)(-1) >= 0 && sizeof (char8_t) == sizeof 
(unsigned char) ? 1 : -1];
           ]])
@@ -129,6 +136,9 @@ AC_DEFUN_ONCE([gl_TYPE_CHAR16_T],
     [gl_cv_type_char16_t_works],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([[
+          #ifdef __HAIKU__
+           #include <stdint.h>
+          #endif
           #include <uchar.h>
           /* For simplicity, assume that uint16_least_t is equivalent to
              'unsigned short'.  */
@@ -152,6 +162,9 @@ AC_DEFUN_ONCE([gl_TYPE_CHAR32_T],
     [gl_cv_type_char32_t_works],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([[
+          #ifdef __HAIKU__
+           #include <stdint.h>
+          #endif
           #include <uchar.h>
           /* For simplicity, assume that uint32_least_t is equivalent to
              'unsigned int'.  */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]