From 9db0ba648a21e644a75c71979fca49a5b083b938 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 18 Jan 2025 20:32:34 +0200 Subject: [PATCH] Refactor SPDLOG_API define --- include/spdlog/common.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 0a54f68b..a12337a3 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -18,24 +18,21 @@ #include "fmt/base.h" #include "fmt/xchar.h" -#if defined(_WIN32) - #ifdef SPDLOG_SHARED_LIB - #ifdef spdlog_EXPORTS - #define SPDLOG_API __declspec(dllexport) - #else - #define SPDLOG_API __declspec(dllimport) - #endif +// Define SPDLOG_API according to current build settings +#ifndef SPDLOG_SHARED_LIB + #define SPDLOG_API +#elif defined(_WIN32) + #ifdef spdlog_EXPORTS + #define SPDLOG_API __declspec(dllexport) // Export symbols when building the library #else - define SPDLOG_API + #define SPDLOG_API __declspec(dllimport) // Import symbols when using the library #endif -#else - // in gcc/clang, always set visibility to "default" -#if defined(__GNUC__) || defined(__clang__) - #define SPDLOG_API __attribute__((visibility("default"))) +#elif (defined(__GNUC__) || defined(__clang__)) + #define SPDLOG_API __attribute__((visibility("default"))) // Export symbols for shared libraries #else #define SPDLOG_API #endif -#endif // defined(_WIN32) +// End of SPDLOG_API definition #define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string) #define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)