Cleanup handling of visibility

This commit is contained in:
Victor Zverovich 2023-09-16 07:40:08 -07:00
parent 016b1faede
commit 6c088be8ec
2 changed files with 13 additions and 17 deletions

View File

@ -185,18 +185,20 @@
# define FMT_END_EXPORT
#endif
#if FMT_GCC_VERSION || defined(__clang__)
# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
#else
# define FMT_VISIBILITY(value)
#endif
#if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
# ifdef FMT_LIB_EXPORT
# define FMT_API __declspec(dllexport)
# elif defined(FMT_SHARED)
# define FMT_API __declspec(dllimport)
# endif
#else
# if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
# if defined(__GNUC__) || defined(__clang__)
# define FMT_API __attribute__((visibility("default")))
# endif
# endif
#elif defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
# define FMT_API FMT_VISIBILITY("default")
#endif
#ifndef FMT_API
# define FMT_API

View File

@ -93,17 +93,11 @@
# define FMT_NO_UNIQUE_ADDRESS
#endif
#if FMT_GCC_VERSION || defined(__clang__)
# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
// Visibility when compiled as a shared library/object.
#if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
# define FMT_SO_VISIBILITY(value) FMT_VISIBILITY(value)
#else
# 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
# define FMT_SO_VISIBILITY(value)
#endif
#ifdef __has_builtin
@ -1053,7 +1047,7 @@ FMT_BEGIN_EXPORT
#endif
/** An error reported from a formatting function. */
class FMT_INLINE_API format_error : public std::runtime_error {
class FMT_SO_VISIBILITY("default") format_error : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};