From 6442963f49526423a13c160883cec881e9667fe7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 6 May 2021 22:01:36 +0100 Subject: [PATCH] Avoid harmless warning about unreachable statement in MSVS build All MSVS versions >= 2015 warn about "return 0" after throw_spdlog_ex() being unreachable in filesize(), so disable this warning in this function (note that it can't be disabled inside it). --- include/spdlog/details/os-inl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index a701e13f..4ed0fa69 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -199,6 +199,12 @@ SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT #endif } +#ifdef _MSC_VER + // avoid warning about unreachable statement at the end of filesize() + #pragma warning(push) + #pragma warning(disable: 4702) +#endif + // Return file size according to open FILE* object SPDLOG_INLINE size_t filesize(FILE *f) { @@ -249,6 +255,10 @@ SPDLOG_INLINE size_t filesize(FILE *f) return 0; // will not be reached. } +#ifdef _MSC_VER + #pragma warning(pop) +#endif + // Return utc offset in minutes or throw spdlog_ex on failure SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {