From 087bfe2b31d68ef74adda9615c6f58b17b09c334 Mon Sep 17 00:00:00 2001 From: denchat <19730041+denchat@users.noreply.github.com> Date: Tue, 13 Apr 2021 11:42:15 +0700 Subject: [PATCH] Create separated FMT_INSTANTIATION_DEF_API Create a separated FMT_INSTANTIATION_DEF_API Create separated FMT_INSTANTIATION_DEF_API and FMT_INSTANTIATION_DECL_API to fix dllexport requirement differences between clang and msvc. - clang: mark dllexport on extern template (template instantiation declaration) in format.h - msvc: mark dllexport on template instantiation definition in format.cc --- include/fmt/core.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 4145bd9e..38a928ad 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -223,8 +223,19 @@ #ifndef FMT_EXTERN_TEMPLATE_API # define FMT_EXTERN_TEMPLATE_API #endif -#ifndef FMT_INSTANTIATION_DECL_API -# define FMT_INSTANTIATION_DECL_API FMT_API +#ifndef FMT_INSTANTIATION_DECL_API // clang marks dllexport at extern template. +# ifndef _MSC_VER +# define FMT_INSTANTIATION_DECL_API FMT_API +# else +# define FMT_INSTANTIATION_DECL_API +# endif +#endif +#ifndef FMT_INSTANTIATION_DEF_API // msvc marks dllexport at the definition itself. +# ifndef _MSC_VER +# define FMT_INSTANTIATION_DEF_API +# else +# define FMT_INSTANTIATION_DEF_API FMT_API +# endif #endif #ifndef FMT_HEADER_ONLY