From 19aea79949c575d768aa678138b20f70df333ca5 Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Tue, 17 Dec 2024 10:29:50 +0800 Subject: [PATCH 1/2] Use the _MSVC_STL_UPDATE macro to detect STL --- include/fmt/ostream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 114b8c297665..d69a4b8cda23 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -35,7 +35,7 @@ class file_access { friend auto get_file(BufType& obj) -> FILE* { return obj.*FileMemberPtr; } }; -#if FMT_MSC_VERSION +#if _MSVC_STL_UPDATE template class file_access; auto get_file(std::filebuf&) -> FILE*; @@ -109,7 +109,7 @@ inline void vprint(std::ostream& os, string_view fmt, format_args args) { auto buffer = memory_buffer(); detail::vformat_to(buffer, fmt, args); FILE* f = nullptr; -#if FMT_MSC_VERSION && FMT_USE_RTTI +#if _MSVC_STL_UPDATE && FMT_USE_RTTI if (auto* buf = dynamic_cast(os.rdbuf())) f = detail::get_file(*buf); #elif defined(_WIN32) && defined(__GLIBCXX__) && FMT_USE_RTTI From b12471446760e256926a760b49cc71c36495b9bb Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Thu, 19 Dec 2024 12:32:20 +0800 Subject: [PATCH 2/2] Prioritize checking if the macro is defined --- include/fmt/ostream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index d69a4b8cda23..17b1e44bdf6a 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -35,7 +35,7 @@ class file_access { friend auto get_file(BufType& obj) -> FILE* { return obj.*FileMemberPtr; } }; -#if _MSVC_STL_UPDATE +#ifdef _MSVC_STL_UPDATE template class file_access; auto get_file(std::filebuf&) -> FILE*; @@ -109,7 +109,7 @@ inline void vprint(std::ostream& os, string_view fmt, format_args args) { auto buffer = memory_buffer(); detail::vformat_to(buffer, fmt, args); FILE* f = nullptr; -#if _MSVC_STL_UPDATE && FMT_USE_RTTI +#if defined(_MSVC_STL_UPDATE) && FMT_USE_RTTI if (auto* buf = dynamic_cast(os.rdbuf())) f = detail::get_file(*buf); #elif defined(_WIN32) && defined(__GLIBCXX__) && FMT_USE_RTTI