diff --git a/include/spdlog/details/console_globals-inl.h b/include/spdlog/details/console_globals-inl.h new file mode 100644 index 00000000..be5da4ea --- /dev/null +++ b/include/spdlog/details/console_globals-inl.h @@ -0,0 +1,26 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#pragma once + +#include "spdlog/common.h" +#include "spdlog/details/console_globals.h" + +namespace spdlog { +namespace details { + +SPDLOG_INLINE console_mutex::mutex_t &console_mutex::mutex() +{ + static mutex_t s_mutex; + return s_mutex; +} + +SPDLOG_INLINE console_nullmutex::mutex_t &console_nullmutex::mutex() +{ + static mutex_t s_mutex; + return s_mutex; +} + +} // namespace details +} // namespace spdlog + diff --git a/include/spdlog/details/console_globals.h b/include/spdlog/details/console_globals.h index 6761a30d..098f1fab 100644 --- a/include/spdlog/details/console_globals.h +++ b/include/spdlog/details/console_globals.h @@ -12,21 +12,17 @@ namespace details { struct console_mutex { using mutex_t = std::mutex; - static mutex_t &mutex() - { - static mutex_t s_mutex; - return s_mutex; - } + static mutex_t &mutex(); }; struct console_nullmutex { using mutex_t = null_mutex; - static mutex_t &mutex() - { - static mutex_t s_mutex; - return s_mutex; - } + static mutex_t &mutex(); }; } // namespace details } // namespace spdlog + +#ifdef SPDLOG_HEADER_ONLY +#include "console_globals-inl.h" +#endif diff --git a/src/spdlog.cpp b/src/spdlog.cpp index be91412d..956384f2 100644 --- a/src/spdlog.cpp +++ b/src/spdlog.cpp @@ -34,6 +34,7 @@ template class spdlog::sinks::rotating_file_sink; template class spdlog::sinks::rotating_file_sink; #include "spdlog/details/registry-inl.h" +#include "spdlog/details/console_globals-inl.h" #include "spdlog/details/os-inl.h" #include "spdlog/details/periodic_worker-inl.h"