Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create separate dllexport marking points for clang and msvc. #2229

Merged
merged 3 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,9 @@ FMT_INLINE uint16_t bsr2log10(int bsr) {
return data[bsr];
}

#ifndef FMT_EXPORTED
FMT_EXTERN template struct FMT_INSTANTIATION_DECL_API basic_data<void>;
#endif

// This is a struct rather than an alias to avoid shadowing warnings in gcc.
struct data : basic_data<> {};
Expand Down
2 changes: 1 addition & 1 deletion src/format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ vformat_to(buffer<char>&, string_view,

// Clang doesn't allow dllexport on template instantiation definitions:
// https://reviews.llvm.org/D61118.
template struct detail::basic_data<void>;
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;

// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
int (*instantiate_format_float)(double, int, detail::float_specs,
Expand Down