aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Zverovich <victor.zverovich@gmail.com>2020-11-12 05:51:00 -0800
committerVictor Zverovich <victor.zverovich@gmail.com>2020-11-24 08:15:59 -0800
commit85534a1397136d5808248289fec68b40e5be0d74 (patch)
tree09cc1e50f7723351db759070184c7d43955ecb76
parenta2fa5d6288b2eb85625d5de5f61efe29604eb878 (diff)
downloadfmtlib-85534a1397136d5808248289fec68b40e5be0d74.tar.gz
Fix linkage errors when linking with a shared library (#2011)
-rw-r--r--.github/workflows/windows.yml44
-rw-r--r--include/fmt/format.h2
-rw-r--r--include/fmt/os.h2
-rw-r--r--src/format.cc4
-rw-r--r--src/os.cc2
5 files changed, 49 insertions, 5 deletions
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
new file mode 100644
index 00000000..f66e2bc9
--- /dev/null
+++ b/.github/workflows/windows.yml
@@ -0,0 +1,44 @@
+name: windows
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ runs-on: ${{matrix.os}}
+ strategy:
+ matrix:
+ # windows-2016 and windows-2019 have MSVC 2017 and 2019 installed
+ # respectively: https://github.com/actions/virtual-environments.
+ 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
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Create Build Environment
+ run: cmake -E make_directory ${{runner.workspace}}/build
+
+ - name: Configure
+ # Use a bash shell for $GITHUB_WORKSPACE.
+ shell: bash
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \
+ -A ${{matrix.platform}} $GITHUB_WORKSPACE
+
+ - name: Build
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --config ${{matrix.build_type}}
+
+ - name: Test
+ working-directory: ${{runner.workspace}}/build
+ run: ctest -C ${{matrix.build_type}}
diff --git a/include/fmt/format.h b/include/fmt/format.h
index 13b8da30..b967afea 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -1274,7 +1274,7 @@ template <typename T> struct decimal_fp {
int exponent;
};
-template <typename T> decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
+template <typename T> FMT_API decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
} // namespace dragonbox
template <typename T>
diff --git a/include/fmt/os.h b/include/fmt/os.h
index d44ea0c9..2482bee5 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<char> {
+class FMT_API ostream final : private detail::buffer<char> {
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<float> dragonbox::to_decimal(float x)
+template FMT_API dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
FMT_NOEXCEPT;
-template dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
+template FMT_API dragonbox::decimal_fp<double> 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