Skip to content

Commit

Permalink
Suppress MSVC warnings in chrono.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsylve committed Aug 30, 2022
1 parent de20679 commit 58f7b2d
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions include/yatlib/chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

#include "features.hpp"

// GCC and Clang use different warning flags for the same issue
#if defined(YAT_IS_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wliteral-suffix"
#elif defined(YAT_IS_CLANG)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuser-defined-literals"
#else
YAT_IGNORE_MSVC_WARNING_PUSH(4455)
#endif

#if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
#define YAT_INTERNAL_USE_STD_CHRONO
#endif
Expand Down Expand Up @@ -172,18 +183,6 @@ using ::date::December;
namespace yat::literals {
inline namespace chrono_literals {

#ifdef YAT_IS_GCC_COMPATIBLE
#pragma GCC diagnostic push

// GCC and Clang use different warning flags for the same issue
#if defined(YAT_IS_GCC)
#pragma GCC diagnostic ignored "-Wliteral-suffix"
#elif defined(YAT_IS_CLANG)
#pragma GCC diagnostic ignored "-Wuser-defined-literals"
#endif

#endif

inline constexpr auto operator"" d(unsigned long long d) noexcept {
return date::literals::operator""_d(d);
}
Expand All @@ -192,13 +191,15 @@ inline constexpr auto operator"" y(unsigned long long y) noexcept {
return date::literals::operator""_y(y);
}

#ifdef YAT_IS_GCC_COMPATIBLE
#pragma GCC diagnostic pop
#endif

} // namespace chrono_literals
} // namespace yat::literals

#endif // !YAT_INTERNAL_USE_STD_CHRONO

#undef YAT_INTERNAL_USE_STD_CHRONO
#undef YAT_INTERNAL_USE_STD_CHRONO

#ifdef YAT_IS_GCC_COMPATIBLE
#pragma GCC diagnostic pop
#else
YAT_IGNORE_MSVC_WARNING_POP()
#endif

0 comments on commit 58f7b2d

Please sign in to comment.