From 8d1d3d012379b53306c041d9cd2709f8716979bb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 9 Jan 2023 09:43:26 +0100 Subject: [PATCH] malloc-h: Fix compilation error in C++ mode on Android. * lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): New macro. --- ChangeLog | 5 +++++ lib/malloc.in.h | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eeeefeca27..394a460a8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-01-09 Bruno Haible + + 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 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 . */ -#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" + 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 -- 2.39.5