aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-05-07 14:14:03 -0400
committerAva Chow <github@achow101.com>2024-05-07 14:14:03 -0400
commit8efd03ad04726aa34219ad83115a3d45030412c3 (patch)
treeae47c7c62b7963b5a2e4f022610591def0cb0d8e
parentef09f535b7b540d997f8c2bfa67b3386711bc8b4 (diff)
parentfa09451f8e6799682d7e7c863f25334fd1c7dce3 (diff)
downloadbitcoin-8efd03ad04726aa34219ad83115a3d45030412c3.tar.xz
Merge bitcoin/bitcoin#29494: build: Assume HAVE_CONFIG_H, Add IWYU pragma keep to bitcoin-config.h includes
fa09451f8e6799682d7e7c863f25334fd1c7dce3 Add lint check for bitcoin-config.h include IWYU pragma (MarcoFalke) dddd40ba8267dea11a3eb03d5cf8b51dbb99be5d scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes (MarcoFalke) Pull request description: The `bitcoin-config.h` includes have issues: * The header is incompatible with iwyu, because symbols may be defined or not defined. So the `IWYU pragma: keep` is needed to keep the include when a symbol is not defined on a platform. Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29408#issuecomment-1948959711 * Guarding the includes by `HAVE_CONFIG_H` is verbose and brittle. Now that all build config dependencies have been removed from low level headers, the benefits are questionable, and the guard can be removed. The linter could also be tricked by guarding the include by `#if defined(HAVE_C0NFIG_H)` (`O` replaced by `0`). Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29404#discussion_r1483189853 . ACKs for top commit: achow101: ACK fa09451f8e6799682d7e7c863f25334fd1c7dce3 TheCharlatan: ACK fa09451f8e6799682d7e7c863f25334fd1c7dce3 hebasto: re-ACK fa09451f8e6799682d7e7c863f25334fd1c7dce3, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/29494#pullrequestreview-2028864535) (`timedata.cpp` removed in https://github.com/bitcoin/bitcoin/pull/29623). Tree-SHA512: 47cb973f7f24bc625acc4e78683371863675d186780236d55d886cf4130e05a78bb04f1d731aae7088313b8e963a9677cc77cf518187dbd99d776f6421ca9b52
-rw-r--r--build-aux/m4/bitcoin_qt.m42
-rw-r--r--build_msvc/bitcoin-qt/bitcoin-qt.vcxproj4
-rw-r--r--build_msvc/common.init.vcxproj.in2
-rw-r--r--src/addrdb.cpp4
-rw-r--r--src/addrman.cpp4
-rw-r--r--src/bench/wallet_create.cpp4
-rw-r--r--src/bench/wallet_ismine.cpp4
-rw-r--r--src/bench/wallet_loading.cpp4
-rw-r--r--src/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp4
-rw-r--r--src/bitcoin-util.cpp4
-rw-r--r--src/bitcoin-wallet.cpp4
-rw-r--r--src/bitcoind.cpp4
-rw-r--r--src/clientversion.cpp4
-rw-r--r--src/clientversion.h4
-rw-r--r--src/common/run_command.cpp4
-rw-r--r--src/common/settings.cpp4
-rw-r--r--src/common/system.cpp4
-rw-r--r--src/common/system.h4
-rw-r--r--src/crypto/sha256.cpp4
-rw-r--r--src/httpserver.cpp4
-rw-r--r--src/init.cpp4
-rw-r--r--src/init/common.cpp4
-rw-r--r--src/mapport.cpp4
-rw-r--r--src/net.cpp4
-rw-r--r--src/netbase.cpp4
-rw-r--r--src/node/interfaces.cpp4
-rw-r--r--src/node/kernel_notifications.cpp4
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/qt/bitcoin.h4
-rw-r--r--src/qt/bitcoingui.cpp4
-rw-r--r--src/qt/bitcoingui.h4
-rw-r--r--src/qt/clientmodel.cpp4
-rw-r--r--src/qt/createwalletdialog.cpp4
-rw-r--r--src/qt/guiutil.cpp4
-rw-r--r--src/qt/intro.cpp4
-rw-r--r--src/qt/modaloverlay.cpp4
-rw-r--r--src/qt/notificator.cpp4
-rw-r--r--src/qt/notificator.h4
-rw-r--r--src/qt/optionsdialog.cpp4
-rw-r--r--src/qt/optionsmodel.cpp4
-rw-r--r--src/qt/qrimagewidget.cpp4
-rw-r--r--src/qt/receiverequestdialog.cpp4
-rw-r--r--src/qt/rpcconsole.cpp4
-rw-r--r--src/qt/rpcconsole.h4
-rw-r--r--src/qt/sendcoinsdialog.cpp4
-rw-r--r--src/qt/splashscreen.cpp4
-rw-r--r--src/qt/test/optiontests.cpp4
-rw-r--r--src/qt/test/test_main.cpp4
-rw-r--r--src/qt/utilitydialog.cpp4
-rw-r--r--src/random.cpp4
-rw-r--r--src/randomenv.cpp4
-rw-r--r--src/rest.cpp4
-rw-r--r--src/rpc/external_signer.cpp4
-rw-r--r--src/rpc/mining.cpp4
-rw-r--r--src/rpc/node.cpp4
-rw-r--r--src/rpc/register.h4
-rw-r--r--src/rpc/server.cpp4
-rw-r--r--src/rpc/util.cpp4
-rw-r--r--src/test/system_tests.cpp4
-rw-r--r--src/test/util/setup_common.cpp4
-rw-r--r--src/test/util_threadnames_tests.cpp4
-rw-r--r--src/util/check.cpp4
-rw-r--r--src/util/fs_helpers.cpp4
-rw-r--r--src/util/syserror.cpp4
-rw-r--r--src/util/threadnames.cpp4
-rw-r--r--src/util/tokenpipe.cpp4
-rw-r--r--src/util/trace.h4
-rw-r--r--src/validation.cpp4
-rw-r--r--src/wallet/init.cpp4
-rw-r--r--src/wallet/rpc/addresses.cpp4
-rw-r--r--src/wallet/rpc/backup.cpp4
-rw-r--r--src/wallet/rpc/wallet.cpp4
-rw-r--r--src/wallet/sqlite.cpp4
-rw-r--r--src/wallet/test/db_tests.cpp4
-rw-r--r--src/wallet/test/util.h4
-rw-r--r--src/wallet/wallet.cpp4
-rw-r--r--src/wallet/walletdb.cpp4
-rw-r--r--src/wallet/wallettool.cpp4
-rw-r--r--src/warnings.cpp4
-rw-r--r--test/lint/test_runner/src/main.rs12
81 files changed, 91 insertions, 237 deletions
diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4
index a716cd9a27..337e2208a9 100644
--- a/build-aux/m4/bitcoin_qt.m4
+++ b/build-aux/m4/bitcoin_qt.m4
@@ -227,7 +227,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
BITCOIN_QT_PATH_PROGS([LUPDATE], [lupdate-qt5 lupdate5 lupdate],$qt_bin_path, yes)
BITCOIN_QT_PATH_PROGS([LCONVERT], [lconvert-qt5 lconvert5 lconvert], $qt_bin_path, yes)
- MOC_DEFS='-DHAVE_CONFIG_H -I$(srcdir)'
+ MOC_DEFS='-I$(srcdir)'
case $host in
*darwin*)
BITCOIN_QT_CHECK([
diff --git a/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj b/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
index fe01da28c8..ff98d37cf8 100644
--- a/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
+++ b/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
@@ -62,7 +62,7 @@
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\src;</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HAVE_CONFIG_H;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
@@ -75,7 +75,7 @@
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\src;</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HAVE_CONFIG_H;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
diff --git a/build_msvc/common.init.vcxproj.in b/build_msvc/common.init.vcxproj.in
index 71fceb6c66..6468abcd06 100644
--- a/build_msvc/common.init.vcxproj.in
+++ b/build_msvc/common.init.vcxproj.in
@@ -90,7 +90,7 @@
<AdditionalOptions>/utf-8 /Zc:preprocessor /Zc:__cplusplus /std:c++20 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4018;4244;4267;4715;4805</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
- <PreprocessorDefinitions>_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;SECP256K1_STATIC;ZMQ_STATIC;NOMINMAX;WIN32;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;_CONSOLE;_WIN32_WINNT=0x0601;_WIN32_IE=0x0501;WIN32_LEAN_AND_MEAN;PROVIDE_FUZZ_MAIN_FUNCTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;SECP256K1_STATIC;ZMQ_STATIC;NOMINMAX;WIN32;_CRT_SECURE_NO_WARNINGS;_CONSOLE;_WIN32_WINNT=0x0601;_WIN32_IE=0x0501;WIN32_LEAN_AND_MEAN;PROVIDE_FUZZ_MAIN_FUNCTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\src;..\..\src\minisketch\include;..\..\src\univalue\include;..\..\src\secp256k1\include;..\..\src\leveldb\include;..\..\src\leveldb\helpers\memenv;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
diff --git a/src/addrdb.cpp b/src/addrdb.cpp
index 14dc314c36..4d34c24ba9 100644
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addrdb.h>
diff --git a/src/addrman.cpp b/src/addrman.cpp
index ef8ed92bb5..eb9c372550 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addrman.h>
#include <addrman_impl.h>
diff --git a/src/bench/wallet_create.cpp b/src/bench/wallet_create.cpp
index d7e772ac82..618d5bc80c 100644
--- a/src/bench/wallet_create.cpp
+++ b/src/bench/wallet_create.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <node/context.h>
diff --git a/src/bench/wallet_ismine.cpp b/src/bench/wallet_ismine.cpp
index 3f922e18a5..753404b526 100644
--- a/src/bench/wallet_ismine.cpp
+++ b/src/bench/wallet_ismine.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif // HAVE_CONFIG_H
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <interfaces/chain.h>
#include <key.h>
diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp
index 6305126c7d..02582deda4 100644
--- a/src/bench/wallet_loading.cpp
+++ b/src/bench/wallet_loading.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <interfaces/chain.h>
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 8901d10ef6..c7ba2204c3 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparamsbase.h>
#include <clientversion.h>
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 320624c419..1c5b0c074c 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparamsbase.h>
#include <clientversion.h>
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp
index 96387e8c71..c8f5bc5026 100644
--- a/src/bitcoin-util.cpp
+++ b/src/bitcoin-util.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <arith_uint256.h>
#include <chain.h>
diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp
index fe90958a5f..bee052bc46 100644
--- a/src/bitcoin-wallet.cpp
+++ b/src/bitcoin-wallet.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <chainparamsbase.h>
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 54796c5abb..7685bdea79 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <clientversion.h>
diff --git a/src/clientversion.cpp b/src/clientversion.cpp
index bf5579ee69..3a5e060a39 100644
--- a/src/clientversion.cpp
+++ b/src/clientversion.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <util/translation.h>
diff --git a/src/clientversion.h b/src/clientversion.h
index 9da0cd0b39..73aaf868e4 100644
--- a/src/clientversion.h
+++ b/src/clientversion.h
@@ -7,9 +7,7 @@
#include <util/macros.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif //HAVE_CONFIG_H
+#include <config/bitcoin-config.h> // IWYU pragma: keep
// Check that required client information is defined
#if !defined(CLIENT_VERSION_MAJOR) || !defined(CLIENT_VERSION_MINOR) || !defined(CLIENT_VERSION_BUILD) || !defined(CLIENT_VERSION_IS_RELEASE) || !defined(COPYRIGHT_YEAR)
diff --git a/src/common/run_command.cpp b/src/common/run_command.cpp
index 347b486095..67608b985f 100644
--- a/src/common/run_command.cpp
+++ b/src/common/run_command.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/run_command.h>
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index db1001111a..c1520dacd2 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -4,9 +4,7 @@
#include <common/settings.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <tinyformat.h>
#include <univalue.h>
diff --git a/src/common/system.cpp b/src/common/system.cpp
index 1fa53a5f34..ddd0feda3b 100644
--- a/src/common/system.cpp
+++ b/src/common/system.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/system.h>
diff --git a/src/common/system.h b/src/common/system.h
index 83280d46ee..d9115d3b33 100644
--- a/src/common/system.h
+++ b/src/common/system.h
@@ -6,9 +6,7 @@
#ifndef BITCOIN_COMMON_SYSTEM_H
#define BITCOIN_COMMON_SYSTEM_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <cstdint>
#include <string>
diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp
index 301f22a248..c883bd2f03 100644
--- a/src/crypto/sha256.cpp
+++ b/src/crypto/sha256.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <crypto/sha256.h>
#include <crypto/common.h>
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 71134d442f..b1d4dc9234 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <httpserver.h>
diff --git a/src/init.cpp b/src/init.cpp
index 1e6d296551..fbf25a0341 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <init.h>
diff --git a/src/init/common.cpp b/src/init/common.cpp
index 0800cd93d8..3a6df3e8bd 100644
--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <common/args.h>
diff --git a/src/mapport.cpp b/src/mapport.cpp
index 08b365db4b..80670230c7 100644
--- a/src/mapport.cpp
+++ b/src/mapport.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <mapport.h>
diff --git a/src/net.cpp b/src/net.cpp
index a3b1fe6d16..ad1e464667 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <net.h>
diff --git a/src/netbase.cpp b/src/netbase.cpp
index f0fa298378..e231766487 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <netbase.h>
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index bb13e53738..84fc92e69d 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -53,9 +53,7 @@
#include <validationinterface.h>
#include <warnings.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <any>
#include <memory>
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
index 99f909ff75..6578b383f7 100644
--- a/src/node/kernel_notifications.cpp
+++ b/src/node/kernel_notifications.cpp
@@ -4,9 +4,7 @@
#include <node/kernel_notifications.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <common/args.h>
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index b1a8461d02..44a858c16b 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoin.h>
diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h
index 9622c9d57d..1423a8bbc6 100644
--- a/src/qt/bitcoin.h
+++ b/src/qt/bitcoin.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_BITCOIN_H
#define BITCOIN_QT_BITCOIN_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/node.h>
#include <qt/initexecutor.h>
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 5f132b817e..a43009d954 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoingui.h>
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index ba91eeb1ff..73adbda5a5 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_BITCOINGUI_H
#define BITCOIN_QT_BITCOINGUI_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoinunits.h>
#include <qt/clientmodel.h>
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 05172cfbd2..2f3bad37e6 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/clientmodel.h>
diff --git a/src/qt/createwalletdialog.cpp b/src/qt/createwalletdialog.cpp
index 6557280d89..3e8d1461e5 100644
--- a/src/qt/createwalletdialog.cpp
+++ b/src/qt/createwalletdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/node.h>
#include <qt/createwalletdialog.h>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index e094b686d4..ee841ce626 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/guiutil.h>
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index 5371dbaa30..26b42deb64 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <qt/intro.h>
diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp
index 667db06574..7bc6ccdc49 100644
--- a/src/qt/modaloverlay.cpp
+++ b/src/qt/modaloverlay.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/modaloverlay.h>
#include <qt/forms/ui_modaloverlay.h>
diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp
index 551c0ffd13..85bdeee49a 100644
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/notificator.h>
diff --git a/src/qt/notificator.h b/src/qt/notificator.h
index 1fd8181a22..8808716aa4 100644
--- a/src/qt/notificator.h
+++ b/src/qt/notificator.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_NOTIFICATOR_H
#define BITCOIN_QT_NOTIFICATOR_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <QIcon>
#include <QObject>
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index dd654a7abe..15103baf59 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/optionsdialog.h>
#include <qt/forms/ui_optionsdialog.h>
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index d0f7c64357..0c21c6748d 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/optionsmodel.h>
diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp
index 00f928b355..f6e712a047 100644
--- a/src/qt/qrimagewidget.cpp
+++ b/src/qt/qrimagewidget.cpp
@@ -15,9 +15,7 @@
#include <QMouseEvent>
#include <QPainter>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h> /* for USE_QRCODE */
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifdef USE_QRCODE
#include <qrencode.h>
diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp
index 3453857f98..b4322ddc0f 100644
--- a/src/qt/receiverequestdialog.cpp
+++ b/src/qt/receiverequestdialog.cpp
@@ -14,9 +14,7 @@
#include <QDialog>
#include <QString>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h> /* for USE_QRCODE */
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
ReceiveRequestDialog::ReceiveRequestDialog(QWidget* parent)
: QDialog(parent, GUIUtil::dialog_flags),
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index bafef62945..702ca44395 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/rpcconsole.h>
#include <qt/forms/ui_debugwindow.h>
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 358f68c3c8..d6a5035c33 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_RPCCONSOLE_H
#define BITCOIN_QT_RPCCONSOLE_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/clientmodel.h>
#include <qt/guiutil.h>
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 89bd35eb1b..0d8c0f7a63 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/sendcoinsdialog.h>
#include <qt/forms/ui_sendcoinsdialog.h>
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 8872f8be32..ffd6689910 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/splashscreen.h>
diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp
index 5f9f2cb449..0f82f65f3e 100644
--- a/src/qt/test/optiontests.cpp
+++ b/src/qt/test/optiontests.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <init.h>
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index c5405cca98..f310d0a02b 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/init.h>
#include <interfaces/node.h>
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 22fe219def..b55b4cbe64 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/utilitydialog.h>
diff --git a/src/random.cpp b/src/random.cpp
index 4fc9099704..239d5bc6fe 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <random.h>
diff --git a/src/randomenv.cpp b/src/randomenv.cpp
index 123b5cc06c..aeec959c28 100644
--- a/src/randomenv.cpp
+++ b/src/randomenv.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <randomenv.h>
diff --git a/src/rest.cpp b/src/rest.cpp
index 89c033b8a3..9fc5d4af04 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <rest.h>
diff --git a/src/rpc/external_signer.cpp b/src/rpc/external_signer.cpp
index 8d06ae4258..27c7394909 100644
--- a/src/rpc/external_signer.cpp
+++ b/src/rpc/external_signer.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <common/system.h>
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index f36665a819..73987669a5 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <chainparams.h>
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp
index ffc2ee5ab0..447be2cf64 100644
--- a/src/rpc/node.cpp
+++ b/src/rpc/node.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <httpserver.h>
diff --git a/src/rpc/register.h b/src/rpc/register.h
index fd23dde75b..65fd29ff08 100644
--- a/src/rpc/register.h
+++ b/src/rpc/register.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_RPC_REGISTER_H
#define BITCOIN_RPC_REGISTER_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
/** These are in one header file to avoid creating tons of single-function
* headers for everything under src/rpc/ */
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index e7d1e3db4e..a800451f4a 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <rpc/server.h>
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 0ac2c4e7b0..22ec4e6967 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <core_io.h>
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp
index 2de147deea..baa759e42c 100644
--- a/src/test/system_tests.cpp
+++ b/src/test/system_tests.cpp
@@ -3,9 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <test/util/setup_common.h>
#include <common/run_command.h>
#include <univalue.h>
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 38350b33cc..0fb5e4eb45 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <test/util/setup_common.h>
diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp
index 45d3a58fd3..df5b1a4461 100644
--- a/src/test/util_threadnames_tests.cpp
+++ b/src/test/util_threadnames_tests.cpp
@@ -11,9 +11,7 @@
#include <thread>
#include <vector>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
diff --git a/src/util/check.cpp b/src/util/check.cpp
index c4d4b0cc28..eb3885832b 100644
--- a/src/util/check.cpp
+++ b/src/util/check.cpp
@@ -4,9 +4,7 @@
#include <util/check.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <tinyformat.h>
diff --git a/src/util/fs_helpers.cpp b/src/util/fs_helpers.cpp
index bce5602462..8952f20f79 100644
--- a/src/util/fs_helpers.cpp
+++ b/src/util/fs_helpers.cpp
@@ -5,9 +5,7 @@
#include <util/fs_helpers.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <logging.h>
#include <sync.h>
diff --git a/src/util/syserror.cpp b/src/util/syserror.cpp
index bac498a23d..6f3a724483 100644
--- a/src/util/syserror.cpp
+++ b/src/util/syserror.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <tinyformat.h>
#include <util/syserror.h>
diff --git a/src/util/threadnames.cpp b/src/util/threadnames.cpp
index 91883fe4ff..ea597dd05a 100644
--- a/src/util/threadnames.cpp
+++ b/src/util/threadnames.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <string>
#include <thread>
diff --git a/src/util/tokenpipe.cpp b/src/util/tokenpipe.cpp
index 3c27d5e523..16fbb664ea 100644
--- a/src/util/tokenpipe.cpp
+++ b/src/util/tokenpipe.cpp
@@ -3,9 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/tokenpipe.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifndef WIN32
diff --git a/src/util/trace.h b/src/util/trace.h
index b7c275f19b..d9ed65e3aa 100644
--- a/src/util/trace.h
+++ b/src/util/trace.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_UTIL_TRACE_H
#define BITCOIN_UTIL_TRACE_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifdef ENABLE_TRACING
diff --git a/src/validation.cpp b/src/validation.cpp
index f57851b4f7..c2b56555a2 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <validation.h>
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index f151fad740..14e988ec1a 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <init.h>
diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp
index bed9ec029a..65587f0b18 100644
--- a/src/wallet/rpc/addresses.cpp
+++ b/src/wallet/rpc/addresses.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <core_io.h>
#include <key_io.h>
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index ae2dfe5795..c05600484e 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <clientversion.h>
diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
index a684d4e191..f1cb595271 100644
--- a/src/wallet/rpc/wallet.cpp
+++ b/src/wallet/rpc/wallet.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <core_io.h>
#include <key_io.h>
diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp
index 34f18bf0b1..5e3a8179a2 100644
--- a/src/wallet/sqlite.cpp
+++ b/src/wallet/sqlite.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/sqlite.h>
diff --git a/src/wallet/test/db_tests.cpp b/src/wallet/test/db_tests.cpp
index f783424df8..438dfceb7f 100644
--- a/src/wallet/test/db_tests.cpp
+++ b/src/wallet/test/db_tests.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h
index 9f2974ece6..a3e6ede81e 100644
--- a/src/wallet/test/util.h
+++ b/src/wallet/test/util.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_WALLET_TEST_UTIL_H
#define BITCOIN_WALLET_TEST_UTIL_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addresstype.h>
#include <wallet/db.h>
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8f4171eb15..45f69f52d1 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -5,9 +5,7 @@
#include <wallet/wallet.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addresstype.h>
#include <blockfilter.h>
#include <chain.h>
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index b1ce7ee4e7..3ba43cdb73 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/walletdb.h>
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
index cda344ab19..7a1930fd31 100644
--- a/src/wallet/wallettool.cpp
+++ b/src/wallet/wallettool.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/wallettool.h>
diff --git a/src/warnings.cpp b/src/warnings.cpp
index 0b1af9b9f0..38c0554cf2 100644
--- a/src/warnings.cpp
+++ b/src/warnings.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <warnings.h>
diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs
index f054f99011..d5dd98effe 100644
--- a/test/lint/test_runner/src/main.rs
+++ b/test/lint/test_runner/src/main.rs
@@ -178,7 +178,6 @@ Please add any false positives, such as subtrees, or externally sourced files to
fn lint_includes_build_config() -> LintResult {
let config_path = "./src/config/bitcoin-config.h.in";
- let include_directive = "#include <config/bitcoin-config.h>";
if !Path::new(config_path).is_file() {
assert!(Command::new("./autogen.sh")
.status()
@@ -235,7 +234,11 @@ fn lint_includes_build_config() -> LintResult {
} else {
"--files-with-matches"
},
- include_directive,
+ if mode {
+ "^#include <config/bitcoin-config.h> // IWYU pragma: keep$"
+ } else {
+ "#include <config/bitcoin-config.h>" // Catch redundant includes with and without the IWYU pragma
+ },
"--",
])
.args(defines_files.lines())
@@ -256,6 +259,11 @@ even though bitcoin-config.h indicates that a faster feature is available and sh
If you are unsure which symbol is used, you can find it with this command:
git grep --perl-regexp '{}' -- file_name
+
+Make sure to include it with the IWYU pragma. Otherwise, IWYU may falsely instruct to remove the
+include again.
+
+#include <config/bitcoin-config.h> // IWYU pragma: keep
"#,
defines_regex
));