Skip to content

Fix build error with MSVC v141 #4413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ using underlying_t = typename std::underlying_type<T>::type;
template <typename T> using decay_t = typename std::decay<T>::type;
using nullptr_t = decltype(nullptr);

#if FMT_GCC_VERSION && FMT_GCC_VERSION < 500
// A workaround for gcc 4.9 to make void_t work in a SFINAE context.
#if (FMT_GCC_VERSION && FMT_GCC_VERSION < 500) || FMT_MSC_VERSION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put more specific MSC version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MSC version depends on the Visual Studio version, but not on the platform toolset. For example:

  • Visual Studio 2017 (v141 toolset) -> _MSC_VER == 1916
  • Visual Studio 2022 (v141 toolset) -> _MSC_VER == 1943
  • Visual Studio 2022 (v143 toolset) -> _MSC_VER == 1943

Because of this, we can't accurately detect the scenario where Visual Studio 2022 is used with the v141 toolset by comparing the value of _MSC_VER. Also, I haven't found a preprocessor definition that provides the platform toolset version.

As a result, I've applied this fix to all MSVC compilers.

Copy link
Contributor

@vitaut vitaut Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. I've corrected the formatting. Also, I've updated the comment to be more accurate: MSVC 2017 -> MSVC v141.

// A workaround for gcc 4.9 and MSVC v141 to make void_t work in a SFINAE
// context.
template <typename...> struct void_t_impl {
using type = void;
};
Expand Down