From: Bruno Haible <bruno@clisp.org> Date: Mon, 9 Jan 2023 08:43:26 +0000 (+0100) Subject: malloc-h: Fix compilation error in C++ mode on Android. X-Git-Tag: v1.0~1878 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8d1d3d012379b53306c041d9cd2709f8716979bb;p=gnulib.git malloc-h: Fix compilation error in C++ mode on Android. * lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): New macro. --- diff --git a/ChangeLog b/ChangeLog index eeeefeca27..394a460a8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-01-09 Bruno Haible <bruno@clisp.org> + + malloc-h: Fix compilation error in C++ mode on Android. + * lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): New macro. + 2023-01-07 Bruno Haible <bruno@clisp.org> timer_time: Rename LIB_TIMER_TIME to TIMER_TIME_LIB. diff --git a/lib/malloc.in.h b/lib/malloc.in.h index de661f0f4b..c39d6e218f 100644 --- a/lib/malloc.in.h +++ b/lib/malloc.in.h @@ -14,18 +14,35 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#ifndef _@GUARD_PREFIX@_MALLOC_H - #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ +#if defined _GL_ALREADY_INCLUDING_MALLOC_H +/* Special invocation convention: + - On Android we have a sequence of nested includes + <malloc.h> -> <stdio.h> -> <sys/stat.h> -> <time.h> -> <sys/time.h> -> + <sys/select.h> -> <signal.h> -> <pthread.h> -> <stdlib.h> -> "malloc.h" + In this situation, in C++ mode, the declaration of memalign might be used + before it actually occurs. */ + +#@INCLUDE_NEXT@ @NEXT_MALLOC_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_MALLOC_H + +#define _GL_ALREADY_INCLUDING_MALLOC_H + /* The include_next requires a split double-inclusion guard. */ #if @HAVE_MALLOC_H@ # @INCLUDE_NEXT@ @NEXT_MALLOC_H@ #endif +#undef _GL_ALREADY_INCLUDING_MALLOC_H + #ifndef _@GUARD_PREFIX@_MALLOC_H #define _@GUARD_PREFIX@_MALLOC_H @@ -83,3 +100,4 @@ _GL_WARN_ON_USE (memalign, "memalign is not portable - " #endif /* _@GUARD_PREFIX@_MALLOC_H */ #endif /* _@GUARD_PREFIX@_MALLOC_H */ +#endif