bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* reallocarray: Fix compilation error in C++ mode on Android
@ 2023-01-09 16:31 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2023-01-09 16:31 UTC (permalink / raw)
  To: bug-gnulib

In a testdir on Android, I get this compilation error:

clang++ -ferror-limit=0 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/data/data/com.termux/files/home/local/include -Wall  -Wno-error -g -O2 -c -o test-stdlib-c++.o ../../gltests/test-stdlib-c++.cc

../gllib/stdlib.h:1722:19: error: use of undeclared identifier 'reallocarray'; did you mean 'gnulib::reallocarray'?
_GL_CXXALIASWARN (reallocarray);
                  ^

The cause is that reallocarray is only declared at higher Android API levels:
/usr/include/malloc.h:void* reallocarray(void* __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur __INTRODUCED_IN(29);

This patch fixes the error.


2023-01-09  Bruno Haible  <bruno@clisp.org>

	reallocarray: Fix compilation error in C++ mode on Android.
	* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Use gl_CHECK_FUNCS_ANDROID
	instead of AC_CHECK_FUNCS.

diff --git a/m4/reallocarray.m4 b/m4/reallocarray.m4
index 1607b7a9ed..4be7cd1be2 100644
--- a/m4/reallocarray.m4
+++ b/m4/reallocarray.m4
@@ -1,4 +1,4 @@
-# reallocarray.m4 serial 3
+# reallocarray.m4 serial 4
 dnl Copyright (C) 2017-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,7 @@ AC_DEFUN([gl_FUNC_REALLOCARRAY],
 
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
-  AC_CHECK_FUNCS([reallocarray])
+  gl_CHECK_FUNCS_ANDROID([reallocarray], [[#include <stdlib.h>]])
   if test "$ac_cv_func_reallocarray" = no; then
     HAVE_REALLOCARRAY=0
   elif test "$gl_cv_malloc_ptrdiff" = no; then





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-09 16:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 16:31 reallocarray: Fix compilation error in C++ mode on Android Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).