From a55083b379f7295a0a6f9be1f963260041a76cc7 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Thu, 26 Apr 2018 14:00:50 -0700 Subject: [PATCH] Symbol visiblity The commits defines a SPDLOG_API to mark classes that should be exported when built as part of a shared library. Only the registry_t class is marked with SPDLOG_API for now. A new entry in tweakme.h has been added, SPDLOG_ENABLE_DLL_IMPORT_EXPORT which default to undefined. If defined, the import / export mechanism will be enabled and if SPDLOG_EXPORTS is defined, the SPDLOG_API will export the symbols, otherwise it will import them. The default behavior is unchanged and SPDLOG_API will expand to nothing. See #693 --- include/spdlog/details/registry.h | 2 +- include/spdlog/tweakme.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 614220d5..a570af94 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -25,7 +25,7 @@ namespace spdlog { namespace details { template -class registry_t +class SPDLOG_API registry_t { public: registry_t(const registry_t &) = delete; diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h index 50ad3fb4..d840a25d 100644 --- a/include/spdlog/tweakme.h +++ b/include/spdlog/tweakme.h @@ -141,3 +141,28 @@ // // #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING", "MY ERROR", "MY CRITICAL", "OFF" } /////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// Uncomment to enable dll symbols export/import. +// You also need to define SPDLOG_EXPORTS when compiling shared library. +// +// #define SPDLOG_ENABLE_DLL_IMPORT_EXPORT +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// This defines the SPDLOG_API macro that allows a class marked with it to be +// exported by a dll. +// Users should define SPDLOG_EXPORTS=1 when compiling a shared library that +// uses spdlog. +#ifdef SPDLOG_ENABLE_DLL_IMPORT_EXPORT +#ifdef SPDLOG_EXPORTS +/*Enabled as "export" while compiling the dll project*/ +#define SPDLOG_API __declspec(dllexport) +#else +/*Enabled as "import" in the Client side for using already created dll file*/ +#define SPDLOG_API __declspec(dllimport) +#endif +#else +#define SPDLOG_API +#endif +///////////////////////////////////////////////////////////////////////////////