From faa3d4f1d8ecff444be53215d72e32d71d9ce138 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 4 Oct 2023 11:06:24 +0200 Subject: [PATCH 1/4] Remove duplicate NDEBUG check from compat/assumptions.h The check is already done in util/check.h, which is more widely included. --- src/compat/assumptions.h | 7 ------- src/net_processing.cpp | 4 ++-- src/validation.cpp | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 4488db08868..78bf3c743f8 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -11,13 +11,6 @@ #include #include -// Assumption: We assume that the macro NDEBUG is not defined. -// Example(s): We use assert(...) extensively with the assumption of it never -// being a noop at runtime. -#if defined(NDEBUG) -# error "Bitcoin cannot be compiled without assertions." -#endif - // Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement). // Example(s): We assume the presence of C++17 features everywhere :-) // ISO Standard C++17 [cpp.predefined]p1: diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 06086d6804a..686da98739b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -16,9 +16,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -39,7 +39,7 @@ #include #include #include -#include // For NDEBUG compile time check +#include #include #include #include diff --git a/src/validation.cpp b/src/validation.cpp index 30b3dde74f0..55f2514202b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -47,7 +47,7 @@ #include #include #include -#include // For NDEBUG compile time check +#include #include #include #include From 77774110f4dd591a71441851813d59c03c9e3c78 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 4 Oct 2023 11:12:09 +0200 Subject: [PATCH 2/4] Remove __cplusplus from compat/assumptions.h It is unclear what the goal of this check is, given that the value may need to be set lower for the mimimum supported version of compilers that forgot to bump the value, see https://github.com/bitcoin/bitcoin/pull/28349#issuecomment-1745143612 . The minimum supported compiler versions are already documented in doc/dependencies.md and using an older compiler will already result in a compile failure, so this check can be removed as redundant. Especially given that it is only included in one file, where iwyu suggests to remove it. --- src/compat/assumptions.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 78bf3c743f8..7b66ab1b159 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -11,13 +11,6 @@ #include #include -// Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement). -// Example(s): We assume the presence of C++17 features everywhere :-) -// 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"); - // Assumption: We assume the floating-point types to fulfill the requirements of // IEC 559 (IEEE 754) standard. // Example(s): Floating-point division by zero in ConnectBlock, CreateTransaction From 88887531b704f3943fdb33abbdd5378ecfeee14f Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 4 Oct 2023 11:29:23 +0200 Subject: [PATCH 3/4] Move compat/assumptions.h include to one place that actually needs it Also add the to avoid removing it by accident. --- src/common/system.h | 1 - src/serialize.h | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/system.h b/src/common/system.h index 40206aaa01d..4b6aa42150a 100644 --- a/src/common/system.h +++ b/src/common/system.h @@ -10,7 +10,6 @@ #include #endif -#include #include #include diff --git a/src/serialize.h b/src/serialize.h index e53ff9fa4c9..dbec620c64c 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -7,7 +7,10 @@ #define BITCOIN_SERIALIZE_H #include +#include // IWYU pragma: keep #include +#include +#include #include #include @@ -18,13 +21,9 @@ #include #include #include -#include #include #include -#include -#include - /** * The maximum size of a serialized object in bytes or number of elements * (for eg vectors) when the size is encoded as CompactSize. From fa1a38470697796a1a67397a815c8f8256f59224 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 16 Oct 2023 14:18:28 +0200 Subject: [PATCH 4/4] Move compat.h include from system.h to system.cpp --- src/common/system.cpp | 3 ++- src/common/system.h | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/common/system.cpp b/src/common/system.cpp index 1d1c5fa56ad..ba42c6df502 100644 --- a/src/common/system.cpp +++ b/src/common/system.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2022 The Bitcoin Core developers +// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -12,6 +12,7 @@ #ifndef WIN32 #include #else +#include #include #endif diff --git a/src/common/system.h b/src/common/system.h index 4b6aa42150a..e8018f9b100 100644 --- a/src/common/system.h +++ b/src/common/system.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2022 The Bitcoin Core developers +// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -10,10 +10,7 @@ #include #endif -#include - -#include -#include +#include #include // Application startup time (used for uptime calculation)