Skip to content

Commit 84f6c69

Browse files
author
MarcoFalke
committed
Merge #21274: assumptions: Assume C++17
5e531e6 assumptions: check C++17 assumption with MSVC (fanquake) c7b4648 assumptions: assume a C++17 compiler (fanquake) Pull request description: This has been the case since #20413. This should also enable the check for 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`. However I have not tested this. ACKs for top commit: laanwj: Code review ACK 5e531e6 hebasto: ACK 5e531e6, checked the MS docs, and AppVeyor build is green. practicalswift: ACK 5e531e6 Tree-SHA512: a4fb525cf5c33abc944c614edb0313a39c8a39a1637a03c09342c15ba0925f4eb037062e65e51b42ade667506b7e554c7159acf86e6b8c35d0a87dd79a6f239b
2 parents c263c3d + 5e531e6 commit 84f6c69

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

build_msvc/common.init.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<ClCompile>
9797
<WarningLevel>Level3</WarningLevel>
9898
<PrecompiledHeader>NotUsing</PrecompiledHeader>
99-
<AdditionalOptions>/utf-8 /std:c++17 %(AdditionalOptions)</AdditionalOptions>
99+
<AdditionalOptions>/utf-8 /Zc:__cplusplus /std:c++17 %(AdditionalOptions)</AdditionalOptions>
100100
<DisableSpecificWarnings>4018;4221;4244;4267;4334;4715;4805;4834</DisableSpecificWarnings>
101101
<TreatWarningAsError>true</TreatWarningAsError>
102102
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>

src/compat/assumptions.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717
# error "Bitcoin cannot be compiled without assertions."
1818
#endif
1919

20-
// Assumption: We assume a C++11 (ISO/IEC 14882:2011) compiler (minimum requirement).
21-
// Example(s): We assume the presence of C++11 features everywhere :-)
22-
// Note: MSVC does not report the expected __cplusplus value due to legacy
23-
// reasons.
24-
#if !defined(_MSC_VER)
25-
// ISO Standard C++11 [cpp.predefined]p1:
26-
// "The name __cplusplus is defined to the value 201103L when compiling a C++
20+
// Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement).
21+
// Example(s): We assume the presence of C++17 features everywhere :-)
22+
// ISO Standard C++17 [cpp.predefined]p1:
23+
// "The name __cplusplus is defined to the value 201703L when compiling a C++
2724
// translation unit."
28-
static_assert(__cplusplus >= 201103L, "C++11 standard assumed");
29-
#endif
25+
static_assert(__cplusplus >= 201703L, "C++17 standard assumed");
3026

3127
// Assumption: We assume the floating-point types to fulfill the requirements of
3228
// IEC 559 (IEEE 754) standard.

0 commit comments

Comments
 (0)