From 85a009ad643a827ff8115452c739e9e8158b505f Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 10 Jan 2023 00:12:03 +0100 Subject: [PATCH] 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 7f22335fb..2ac8cc3f5 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 {