diff --git a/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj b/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
index fe01da28c880aa..ff98d37cf89fed 100644
--- a/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
+++ b/build_msvc/bitcoin-qt/bitcoin-qt.vcxproj
@@ -62,7 +62,7 @@
..\..\src;
- HAVE_CONFIG_H;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ _UNICODE;UNICODE;%(PreprocessorDefinitions)
@@ -75,7 +75,7 @@
..\..\src;
- HAVE_CONFIG_H;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ _UNICODE;UNICODE;%(PreprocessorDefinitions)
diff --git a/build_msvc/common.init.vcxproj.in b/build_msvc/common.init.vcxproj.in
index 950cc37f0a3a67..267cfcccf67e57 100644
--- a/build_msvc/common.init.vcxproj.in
+++ b/build_msvc/common.init.vcxproj.in
@@ -90,7 +90,7 @@
/utf-8 /Zc:__cplusplus /std:c++20 %(AdditionalOptions)
4018;4244;4267;4715;4805
true
- _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;%(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;%(PreprocessorDefinitions)
..\..\src;..\..\src\minisketch\include;..\..\src\univalue\include;..\..\src\secp256k1\include;..\..\src\leveldb\include;..\..\src\leveldb\helpers\memenv;%(AdditionalIncludeDirectories)
diff --git a/src/script/bitcoinconsensus.h b/src/script/bitcoinconsensus.h
index a202b5ba065c2b..8e46bd2587a002 100644
--- a/src/script/bitcoinconsensus.h
+++ b/src/script/bitcoinconsensus.h
@@ -8,8 +8,8 @@
#include
-#if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H)
-#include
+#if defined(BUILD_BITCOIN_INTERNAL)
+#include // IWYU pragma: keep
#if defined(_WIN32)
#if defined(HAVE_DLLEXPORT_ATTRIBUTE)
#define EXPORT_SYMBOL __declspec(dllexport)
diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs
index b97e822484bf73..5dc55214c0a584 100644
--- a/test/lint/test_runner/src/main.rs
+++ b/test/lint/test_runner/src/main.rs
@@ -97,7 +97,6 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
fn lint_includes_build_config() -> LintResult {
let config_path = "./src/config/bitcoin-config.h.in";
- let include_directive = "#include ";
if !Path::new(config_path).is_file() {
assert!(Command::new("./autogen.sh")
.status()
@@ -154,7 +153,11 @@ fn lint_includes_build_config() -> LintResult {
} else {
"--files-with-matches"
},
- include_directive,
+ if mode {
+ "^#include // IWYU pragma: keep$"
+ } else {
+ "#include " // Catch redundant includes with and without the IWYU pragma
+ },
"--",
])
.args(defines_files.lines())
@@ -175,6 +178,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 // IWYU pragma: keep
"#,
defines_regex
));