From 3da01e3753bc3be7e90fe7dabd62cf0781dc2289 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Sun, 7 Apr 2024 13:50:00 +0200 Subject: [PATCH] Worked around error C2572: 'std::enable_if': redefinition of default argument: parameter 1 All std C++ headers are hidden and replaced with import std. Some std C headers are added. Cfr. https://developercommunity.visualstudio.com/t/VS2022-175-Preview-3---Compiler-bug-wit/10256508 --- include/fmt/args.h | 8 +++-- include/fmt/base.h | 14 +++++--- include/fmt/chrono.h | 20 ++++++----- include/fmt/compile.h | 4 ++- include/fmt/format-inl.h | 16 +++++---- include/fmt/format.h | 32 +++++++++++------ include/fmt/os.h | 10 +++--- include/fmt/ostream.h | 4 ++- include/fmt/printf.h | 6 ++-- include/fmt/ranges.h | 10 +++--- include/fmt/std.h | 48 ++++++++++++++++--------- include/fmt/xchar.h | 8 +++-- src/fmt.cc | 77 +++++++++++++++++++++++----------------- src/os.cc | 4 ++- 14 files changed, 163 insertions(+), 98 deletions(-) diff --git a/include/fmt/args.h b/include/fmt/args.h index b77a2d066112..0a93c1753f38 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -8,9 +8,11 @@ #ifndef FMT_ARGS_H_ #define FMT_ARGS_H_ -#include // std::reference_wrapper -#include // std::unique_ptr -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::reference_wrapper +//#include // std::unique_ptr +//#include +// DIVERGENCE END #include "format.h" // std_string_view diff --git a/include/fmt/base.h b/include/fmt/base.h index 91015edfae64..a249673f2ecd 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -8,13 +8,17 @@ #ifndef FMT_BASE_H_ #define FMT_BASE_H_ -#include // CHAR_BIT -#include // FILE -#include // strlen +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // CHAR_BIT +//#include // FILE +//#include // strlen +// DIVERGENCE END // is also included transitively from . -#include // std::byte -#include // std::enable_if +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::byte +//#include // std::enable_if +// DIVERGENCE END // The fmt library version in the form major * 10000 + minor * 100 + patch. #define FMT_VERSION 100202 diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index d2e10b56b933..d6589f14f3b4 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -8,15 +8,17 @@ #ifndef FMT_CHRONO_H_ #define FMT_CHRONO_H_ -#include -#include -#include // std::isfinite -#include // std::memcpy -#include -#include -#include -#include -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include +//#include // std::isfinite +//#include // std::memcpy +//#include +//#include +//#include +//#include +//#include +// DIVERGENCE END #include "format.h" diff --git a/include/fmt/compile.h b/include/fmt/compile.h index d6278521fd0c..01e3e83c7b82 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -8,7 +8,9 @@ #ifndef FMT_COMPILE_H_ #define FMT_COMPILE_H_ -#include // std::back_inserter +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::back_inserter +// DIVERGENCE END #include "format.h" diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index dfd96b49b54e..86d8540cfa99 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -8,14 +8,18 @@ #ifndef FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_ -#include -#include // errno -#include -#include -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include // errno +//#include +//#include +//#include +// DIVERGENCE END #ifndef FMT_STATIC_THOUSANDS_SEPARATOR -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END #endif #if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE) diff --git a/include/fmt/format.h b/include/fmt/format.h index d146ec34ee4b..d6f1d31ac6fd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -38,30 +38,40 @@ # define FMT_REMOVE_TRANSITIVE_INCLUDES #endif -#include // std::signbit -#include // uint32_t -#include // std::memcpy -#include // std::initializer_list -#include // std::numeric_limits +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::signbit +//#include // uint32_t +//#include // std::memcpy +//#include // std::initializer_list +//#include // std::numeric_limits +// DIVERGENCE END #if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI) // Workaround for pre gcc 5 libstdc++. -# include // std::allocator_traits +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include // std::allocator_traits +// DIVERGENCE END #endif -#include // std::runtime_error -#include // std::string -#include // std::system_error +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::runtime_error +//#include // std::string +//#include // std::system_error +// DIVERGENCE END #include "base.h" // Checking FMT_CPLUSPLUS for warning suppression in MSVC. #if FMT_HAS_INCLUDE() && FMT_CPLUSPLUS > 201703L -# include // std::bit_cast +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include // std::bit_cast +// DIVERGENCE END #endif // libc++ supports string_view in pre-c++17. #if FMT_HAS_INCLUDE() && \ (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END # define FMT_USE_STRING_VIEW #endif diff --git a/include/fmt/os.h b/include/fmt/os.h index 3a10c9303f11..b049c43f24b9 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -8,10 +8,12 @@ #ifndef FMT_OS_H_ #define FMT_OS_H_ -#include -#include -#include -#include // std::system_error +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include +//#include +//#include // std::system_error +// DIVERGENCE END #include "format.h" diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index f9ba9d7b25b6..89fbbba954af 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -8,7 +8,9 @@ #ifndef FMT_OSTREAM_H_ #define FMT_OSTREAM_H_ -#include // std::filebuf +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::filebuf +// DIVERGENCE END #ifdef _WIN32 # ifdef __GLIBCXX__ diff --git a/include/fmt/printf.h b/include/fmt/printf.h index c060952d9e8b..81fb0ae34215 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -8,8 +8,10 @@ #ifndef FMT_PRINTF_H_ #define FMT_PRINTF_H_ -#include // std::max -#include // std::numeric_limits +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include // std::max +//#include // std::numeric_limits +// DIVERGENCE END #include "format.h" diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index f2b0f0e944dc..3b4fc14940ff 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -8,10 +8,12 @@ #ifndef FMT_RANGES_H_ #define FMT_RANGES_H_ -#include -#include -#include -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include +//#include +//#include +// DIVERGENCE END #include "format.h" diff --git a/include/fmt/std.h b/include/fmt/std.h index 7085cae8170a..91e707e814e8 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -8,43 +8,57 @@ #ifndef FMT_STD_H_ #define FMT_STD_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +// DIVERGENCE END #include "format.h" #include "ostream.h" #if FMT_HAS_INCLUDE() -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END #endif // Checking FMT_CPLUSPLUS for warning suppression in MSVC. #if FMT_CPLUSPLUS >= 201703L # if FMT_HAS_INCLUDE() -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END # endif # if FMT_HAS_INCLUDE() -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END # endif # if FMT_HAS_INCLUDE() -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END # endif #endif #if FMT_HAS_INCLUDE() && FMT_CPLUSPLUS > 202002L -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END #endif #if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE() -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END #endif // GCC 4 does not support FMT_HAS_INCLUDE. diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 61a4b54fca5d..98e08f11fd1b 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -8,14 +8,18 @@ #ifndef FMT_XCHAR_H_ #define FMT_XCHAR_H_ -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +// DIVERGENCE END #include "color.h" #include "format.h" #include "ranges.h" #ifndef FMT_STATIC_THOUSANDS_SEPARATOR -# include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//# include +// DIVERGENCE END #endif FMT_BEGIN_NAMESPACE diff --git a/src/fmt.cc b/src/fmt.cc index 6cff309d41c6..05c9189af3af 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -2,38 +2,47 @@ module; // Put all implementation-provided headers into the global module fragment // to prevent attachment to this module. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +// DIVERGENCE END + +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +#include +#include +#include +#include +// DIVERGENCE END #if __has_include() # include @@ -70,6 +79,10 @@ module; export module fmt; +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +import std; +// DIVERGENCE END + #define FMT_EXPORT export #define FMT_BEGIN_EXPORT export { #define FMT_END_EXPORT } diff --git a/src/os.cc b/src/os.cc index 30bb0a6f1b00..a2926e6d0f22 100644 --- a/src/os.cc +++ b/src/os.cc @@ -12,7 +12,9 @@ #include "fmt/os.h" -#include +// DIVERGENCE BEGIN - Worked around std imports and includes mixing +//#include +// DIVERGENCE END #if FMT_USE_FCNTL # include