From c7b46489f8c4d880382248fb47266d81948bbce0 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 23 Feb 2021 12:48:15 +0800 Subject: [PATCH 1/2] assumptions: assume a C++17 compiler This has already been the case since #20413. --- src/compat/assumptions.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 301c2d914cf..e8d0c7d56e7 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -17,15 +17,15 @@ # error "Bitcoin cannot be compiled without assertions." #endif -// Assumption: We assume a C++11 (ISO/IEC 14882:2011) compiler (minimum requirement). -// Example(s): We assume the presence of C++11 features everywhere :-) +// Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement). +// Example(s): We assume the presence of C++17 features everywhere :-) // Note: MSVC does not report the expected __cplusplus value due to legacy // reasons. #if !defined(_MSC_VER) -// ISO Standard C++11 [cpp.predefined]p1: -// "The name __cplusplus is defined to the value 201103L when compiling a C++ +// ISO Standard C++17 [cpp.predefined]p1: +// "The name __cplusplus is defined to the value 201703L when compiling a C++ // translation unit." -static_assert(__cplusplus >= 201103L, "C++11 standard assumed"); +static_assert(__cplusplus >= 201703L, "C++17 standard assumed"); #endif // Assumption: We assume the floating-point types to fulfill the requirements of From 5e531e6beb5381c0be5efaa24b7e423e593568e4 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 23 Feb 2021 12:49:56 +0800 Subject: [PATCH 2/2] assumptions: check C++17 assumption with MSVC From my reading of https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160 and https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ if we set the `/Zc:__cplusplus` switch in additional options, MSVC will report the correct value for `__cplusplus`. --- build_msvc/common.init.vcxproj | 2 +- src/compat/assumptions.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/build_msvc/common.init.vcxproj b/build_msvc/common.init.vcxproj index 9c589bccbc4..a3487c7a0d5 100644 --- a/build_msvc/common.init.vcxproj +++ b/build_msvc/common.init.vcxproj @@ -96,7 +96,7 @@ Level3 NotUsing - /utf-8 /std:c++17 %(AdditionalOptions) + /utf-8 /Zc:__cplusplus /std:c++17 %(AdditionalOptions) 4018;4221;4244;4267;4334;4715;4805;4834 true _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;ZMQ_STATIC;NOMINMAX;WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_CONSOLE;_WIN32_WINNT=0x0601;_WIN32_IE=0x0501;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index e8d0c7d56e7..5f50cde3ff6 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -19,14 +19,10 @@ // Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement). // Example(s): We assume the presence of C++17 features everywhere :-) -// Note: MSVC does not report the expected __cplusplus value due to legacy -// reasons. -#if !defined(_MSC_VER) // ISO Standard C++17 [cpp.predefined]p1: // "The name __cplusplus is defined to the value 201703L when compiling a C++ // translation unit." static_assert(__cplusplus >= 201703L, "C++17 standard assumed"); -#endif // Assumption: We assume the floating-point types to fulfill the requirements of // IEC 559 (IEEE 754) standard.