]> Savannah Git Hosting - gnulib.git/commitdiff
malloc-h: Fix compilation error in C++ mode on Android.
authorBruno Haible <bruno@clisp.org>
Mon, 9 Jan 2023 08:43:26 +0000 (09:43 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 9 Jan 2023 08:54:18 +0000 (09:54 +0100)
* lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): New macro.

ChangeLog
lib/malloc.in.h

index eeeefeca27ca3855b226f4357e09f9745116a1a0..394a460a8ec6b0226fbf511df5e46f0e0c78e51d 100644 (file)
--- 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.
index de661f0f4b728682d7e559f3f62557ea66e4170c..c39d6e218f7eb89a63ede3a509e7e3b601b5b252 100644 (file)
    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