From 6d14f7811516ff1a88aff6edbd8c46e607aa7f07 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 12 Nov 2020 05:51:00 -0800 Subject: [PATCH] Fix linkage errors when linking with a shared library (#2011) --- .github/workflows/windows.yml | 7 ++++++- include/fmt/format.h | 4 ++-- include/fmt/os.h | 2 +- src/format.cc | 4 ++-- src/os.cc | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1fc3689b..f66e2bc9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,6 +12,11 @@ jobs: os: [windows-2016, windows-2019] platform: [Win32, x64] build_type: [Debug, Release] + include: + - os: windows-2016 + platform: Win32 + build_type: Debug + shared: -DBUILD_SHARED_LIBS=ON exclude: - os: windows-2016 platform: Win32 @@ -27,7 +32,7 @@ jobs: shell: bash working-directory: ${{runner.workspace}}/build run: | - cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \ -A ${{matrix.platform}} $GITHUB_WORKSPACE - name: Build diff --git a/include/fmt/format.h b/include/fmt/format.h index 9aca3b5d..b18303b0 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -37,9 +37,9 @@ #include #include #include +#include #include #include // std::swap -#include #include "core.h" @@ -1295,7 +1295,7 @@ template struct decimal_fp { int exponent; }; -template decimal_fp to_decimal(T x) FMT_NOEXCEPT; +template FMT_API decimal_fp to_decimal(T x) FMT_NOEXCEPT; } // namespace dragonbox template diff --git a/include/fmt/os.h b/include/fmt/os.h index e91a2af5..301374c2 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -378,7 +378,7 @@ struct ostream_params { static constexpr detail::buffer_size buffer_size; // A fast output stream which is not thread-safe. -class ostream final : private detail::buffer { +class FMT_API ostream final : private detail::buffer { private: file file_; diff --git a/src/format.cc b/src/format.cc index bca87b03..6141d964 100644 --- a/src/format.cc +++ b/src/format.cc @@ -24,9 +24,9 @@ int format_float(char* buf, std::size_t size, const char* format, int precision, : snprintf_ptr(buf, size, format, precision, value); } -template dragonbox::decimal_fp dragonbox::to_decimal(float x) +template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(float x) FMT_NOEXCEPT; -template dragonbox::decimal_fp dragonbox::to_decimal(double x) +template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(double x) FMT_NOEXCEPT; // DEPRECATED! This function exists for ABI compatibility. diff --git a/src/os.cc b/src/os.cc index a07e7824..68500245 100644 --- a/src/os.cc +++ b/src/os.cc @@ -315,7 +315,7 @@ long getpagesize() { # endif } -void ostream::grow(size_t) { +FMT_API void ostream::grow(size_t) { if (this->size() == this->capacity()) flush(); } #endif // FMT_USE_FCNTL