From 0117937ed8ba7cbfc579517e58e39b37dd2dc666 Mon Sep 17 00:00:00 2001 From: Michal Mikula Date: Wed, 7 Oct 2026 07:35:30 +0200 Subject: [PATCH] Fix compilation on MSVC where __cplusplus macro is old --- include/croncpp.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/croncpp.h b/include/croncpp.h index 4306a04..ea4b1c1 100644 --- a/include/croncpp.h +++ b/include/croncpp.h @@ -12,7 +12,13 @@ #include #include -#if __cplusplus > 201402L +#if defined(_MSVC_LANG) +#define CRONCPP_CPLUSPLUS _MSVC_LANG +#else +#define CRONCPP_CPLUSPLUS __cplusplus +#endif + +#if CRONCPP_CPLUSPLUS > 201402L #include #define CRONCPP_IS_CPP17 #endif @@ -375,7 +381,7 @@ namespace cron inline std::tm to_tm(CRONCPP_STRING_VIEW time) { std::tm result; -#if __cplusplus > 201103L +#if CRONCPP_CPLUSPLUS > 201103L std::istringstream str(time.data()); str.imbue(std::locale(setlocale(LC_ALL, nullptr))); @@ -403,7 +409,7 @@ namespace cron inline std::string to_string(std::tm const & tm) { -#if __cplusplus > 201103L +#if CRONCPP_CPLUSPLUS > 201103L std::ostringstream str; str.imbue(std::locale(setlocale(LC_ALL, nullptr))); str << std::put_time(&tm, "%Y-%m-%d %H:%M:%S");