From ef7674443d9a1db28659c1ef878e485ef1417a00 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Wed, 27 Oct 2021 12:30:32 +0200 Subject: [PATCH] Set visibility "default" only when exporting GCC-like compilers only export symbols when ``MI_SHARED_LIB`` and ``MI_SHARED_LIB_EXPORT`` are defined. Fixes: https://github.com/microsoft/mimalloc/issues/475 Signed-off-by: Christian Heimes --- include/mimalloc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/mimalloc.h b/include/mimalloc.h index 7ebf3e60..91b5449d 100644 --- a/include/mimalloc.h +++ b/include/mimalloc.h @@ -59,7 +59,11 @@ terms of the MIT license. A copy of the license can be found in the file #define mi_attr_alloc_align(p) #elif defined(__GNUC__) // includes clang and icc #define mi_cdecl // leads to warnings... __attribute__((cdecl)) - #define mi_decl_export __attribute__((visibility("default"))) + #if defined(MI_SHARED_LIB) && defined(MI_SHARED_LIB_EXPORT) + #define mi_decl_export __attribute__((visibility("default"))) + #else + #define mi_decl_export + #endif #define mi_decl_restrict #define mi_attr_malloc __attribute__((malloc)) #if (defined(__clang_major__) && (__clang_major__ < 4)) || (__GNUC__ < 5)