From 85a009ad643a827ff8115452c739e9e8158b505f Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 10 Jan 2023 00:12:03 +0100 Subject: [PATCH 1/3] Support newlib C library configurations without tm_gmtoff field (#2600) Newlib C library (https://sourceware.org/newlib/) has a configuration option to add tm_gmtoff field to the tm structure. Not all the platforms supported by newlib enable this option, and spdlog doesn't compile on such platforms due to missing tm_gmtoff field. Fix this by checking for `__NEWLIB__` and `__TM_GMTOFF` and enabling calculate_gmt_offset. --- include/spdlog/details/os-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index 7f22335f..2ac8cc3f 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -286,7 +286,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) return offset; #else -# if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE)) +# if defined(sun) || defined(__sun) || defined(_AIX) || (defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE)) // 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris struct helper { From 0b9ff5210a95149b1cfcb8a66bf53d34f2b6d30d Mon Sep 17 00:00:00 2001 From: Arnar Bjarni Arnarson Date: Mon, 9 Jan 2023 23:25:01 +0000 Subject: [PATCH 2/3] Fix type of event id in win_eventlog_sink (#2598) Co-authored-by: Arnar Bjarni Arnarson --- include/spdlog/sinks/win_eventlog_sink.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/spdlog/sinks/win_eventlog_sink.h b/include/spdlog/sinks/win_eventlog_sink.h index 2f2aacb5..def4b135 100644 --- a/include/spdlog/sinks/win_eventlog_sink.h +++ b/include/spdlog/sinks/win_eventlog_sink.h @@ -210,7 +210,7 @@ private: HANDLE hEventLog_{NULL}; internal::sid_t current_user_sid_; std::string source_; - WORD event_id_; + DWORD event_id_; HANDLE event_log_handle() { @@ -258,7 +258,7 @@ protected: void flush_() override {} public: - win_eventlog_sink(std::string const &source, WORD event_id = 1000 /* according to mscoree.dll */) + win_eventlog_sink(std::string const &source, DWORD event_id = 1000 /* according to mscoree.dll */) : source_(source) , event_id_(event_id) { From 6df64c6c34997e298a81150b9ce55c440c6f503f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Lind=C3=A9n?= Date: Tue, 10 Jan 2023 00:25:26 +0100 Subject: [PATCH 3/3] Fix -Wshadow warnings in spdlog::sinks::dist_sink (#2599) This is similar to fbba6dff20b0c04a0694515168914a62161999d7 but fixes a few member functions missed in that commit. --- include/spdlog/sinks/dist_sink.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/spdlog/sinks/dist_sink.h b/include/spdlog/sinks/dist_sink.h index 065048ad..7ec3a2ec 100644 --- a/include/spdlog/sinks/dist_sink.h +++ b/include/spdlog/sinks/dist_sink.h @@ -31,16 +31,16 @@ public: dist_sink(const dist_sink &) = delete; dist_sink &operator=(const dist_sink &) = delete; - void add_sink(std::shared_ptr sink) + void add_sink(std::shared_ptr sub_sink) { std::lock_guard lock(base_sink::mutex_); - sinks_.push_back(sink); + sinks_.push_back(sub_sink); } - void remove_sink(std::shared_ptr sink) + void remove_sink(std::shared_ptr sub_sink) { std::lock_guard lock(base_sink::mutex_); - sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sink), sinks_.end()); + sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sub_sink), sinks_.end()); } void set_sinks(std::vector> sinks)