Skip to content

Commit

Permalink
Fix symbol leak (#3627)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
  • Loading branch information
phprus committed Sep 16, 2023
1 parent e253700 commit 016b1fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
# define FMT_VISIBILITY(value)
#endif

#if !defined(FMT_HEADER_ONLY) && !defined(_WIN32) && \
(defined(FMT_LIB_EXPORT) || defined(FMT_SHARED))
# define FMT_INLINE_API FMT_VISIBILITY("default")
#else
# define FMT_INLINE_API
#endif

#ifdef __has_builtin
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
#else
Expand Down Expand Up @@ -1046,7 +1053,7 @@ FMT_BEGIN_EXPORT
#endif

/** An error reported from a formatting function. */
class FMT_VISIBILITY("default") format_error : public std::runtime_error {
class FMT_INLINE_API format_error : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
Expand Down
4 changes: 4 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ TEST(memory_buffer_test, max_size_allocator_overflow) {
EXPECT_THROW(buffer.resize(161), std::exception);
}

TEST(format_test, exception_from_lib) {
EXPECT_THROW_MSG(fmt::throw_format_error("test"), format_error, "test");
}

TEST(format_test, escape) {
EXPECT_EQ("{", fmt::format("{{"));
EXPECT_EQ("before {", fmt::format("before {{"));
Expand Down

0 comments on commit 016b1fa

Please sign in to comment.