diff --git a/include/fmt/core.h b/include/fmt/core.h index d27cb06c..f1cbc795 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -233,8 +233,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 diff --git a/include/fmt/format.h b/include/fmt/format.h index d8b52d91..88fc418a 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -998,7 +998,9 @@ FMT_INLINE uint16_t bsr2log10(int bsr) { return data[bsr]; } +#ifndef FMT_EXPORTED FMT_EXTERN template struct FMT_INSTANTIATION_DECL_API basic_data; +#endif // This is a struct rather than an alias to avoid shadowing warnings in gcc. struct data : basic_data<> {}; diff --git a/src/format.cc b/src/format.cc index 54f4ad45..3a53f3a1 100644 --- a/src/format.cc +++ b/src/format.cc @@ -57,7 +57,7 @@ vformat_to(buffer&, string_view, // Clang doesn't allow dllexport on template instantiation definitions: // https://reviews.llvm.org/D61118. -template struct detail::basic_data; +template struct FMT_INSTANTIATION_DEF_API detail::basic_data; // Workaround a bug in MSVC2013 that prevents instantiation of format_float. int (*instantiate_format_float)(double, int, detail::float_specs,