bug-gnulib
[Top][All Lists]
Advanced

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

random_r: Fix compilation error on Haiku


From: Bruno Haible
Subject: random_r: Fix compilation error on Haiku
Date: Wed, 05 Apr 2023 22:10:21 +0200

On Haiku, in a testdir for 'random_r', I see this compilation error:

g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I..  -DGNULIB_STRICT_CHECKING=1 
-DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib -I./../gllib   -Wno-error -g 
-O2 -MT test-stdlib-c++.o -MD -MP -MF $depbase.Tpo -c -o test-stdlib-c++.o 
test-stdlib-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /boot/system/develop/headers/posix/sys/types.h:127,
                 from ../gllib/sys/types.h:39,
                 from /boot/system/develop/headers/posix/stdlib.h:13,
                 from /boot/system/develop/headers/gnu/stdlib.h:13,
                 from /boot/system/develop/headers/bsd/stdlib.h:9,
                 from 
/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/11.2.0/include/c++/cstdlib:75,
                 from 
/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/11.2.0/include/c++/stdlib.h:36,
                 from ../gllib/stdlib.h:36,
                 from test-stdlib-c++.cc:22:
../gllib/stdlib.h:1723:1: error: 'int32_t' has not been declared
 1723 | _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t 
*result));
      | ^~~~~~~~~~~~~~~~

On this platform, <stdlib.h> declares random_r with an 'int *' parameter
instead of an 'int32_t *' parameter — which is OK, since these types are
equivalent — and without including <stdint.h>. Since int32_t occurs in
Gnulib's declaration for this function, we need to include <stdint.h>.

This patch fixes it.


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

        random_r: Fix compilation error on Haiku.
        * lib/stdlib.in.h: For random_r, include <stdint.h> always.
        * modules/random_r (Depends-on): Depend on 'stdint' always.

diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index c18a16bacd..f79c5a9d29 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -67,9 +67,7 @@
 #  include <random.h>
 # endif
 
-# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
-#  include <stdint.h>
-# endif
+# include <stdint.h>
 
 # if !@HAVE_STRUCT_RANDOM_DATA@
 /* Define 'struct random_data'.
diff --git a/modules/random_r b/modules/random_r
index 56c5a447e9..6ae9c6db58 100644
--- a/modules/random_r
+++ b/modules/random_r
@@ -9,7 +9,7 @@ Depends-on:
 c99
 libc-config     [test $HAVE_RANDOM_R = 0 || test $REPLACE_RANDOM_R = 1]
 stdlib
-stdint          [test $HAVE_RANDOM_R = 0 || test $REPLACE_RANDOM_R = 1]
+stdint
 
 configure.ac:
 gl_FUNC_RANDOM_R






reply via email to

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