From 876cbbc97706af8e12c03ebea440f06e891a55e5 Mon Sep 17 00:00:00 2001
From: Basile Desloges <basile.desloges@cea.fr>
Date: Thu, 15 Oct 2020 14:46:58 +0200
Subject: [PATCH] [eacsl] Update dlmalloc to support MinGW compilation

---
 src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.c b/src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.c
index be59fec2502..1e7d5016f84 100644
--- a/src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.c
+++ b/src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.c
@@ -797,7 +797,17 @@ struct mallinfo {
   Try to persuade compilers to inline. The most critical functions for
   inlining are defined as macros, so these aren't used for them.
 */
-
+// MinGW defines `FORCEINLINE` as `__forceinline`, and defines `__forceinline`
+// with an "extern" storage class. Since the macro `FORCEINLINE` is used here
+// on `static` function, a compilation error occurs because `static` and
+// `extern` cannot be used at the same time.
+// This implementation "problem" is known to the MinGW team but is explicitely
+// marked as "won't fix": https://sourceforge.net/p/mingw-w64/bugs/269/
+// So the workaround here is to `undef FORCEINLINE` if the file is being
+// compiled by MinGW.
+#ifdef __MINGW32__ // defined for 32 bits and 64 bits MinGW
+#undef FORCEINLINE
+#endif
 #ifndef FORCEINLINE
   #if defined(__GNUC__)
 #define FORCEINLINE __inline __attribute__ ((always_inline))
-- 
GitLab