Skip to content

Commit f8befc8

Browse files
authored
fix: add missing includes and remove obsolete includes (#5562)
## Issue being fixed or feature implemented Some headers or modules are used objects from STL without including it directly, it cause compilation failures on some platforms for some specific compilers such as #5554 ## What was done? Added missing includes and removed obsolete includes for `optional`, `deque`, `tuple`, `unordered_set`, `unordered_map`, `set` and `atomic`. Please, note, that this PR doesn't cover all cases, only cases when it is obviously missing or obviously obsolete. Also most of changes belongs to to dash specific code; but for cases of original bitcoin code I keep it untouched, such as missing <map> in `src/psbt.h` I used this script to get a list of files/headers which looks suspicious `./headers-scanner.sh std::optional optional`: ```bash #!/bin/bash set -e function check_includes() { obj=$1 header=$2 file=$3 used=0 included=0 grep "$obj" "$file" >/dev/null 2>/dev/null && used=1 grep "include <$header>" $file >/dev/null 2>/dev/null && included=1 if [ $used == 1 ] && [ $included == 0 ] then echo "missing <$header> in $file" fi if [ $used == 0 ] && [ $included == 1 ] then echo "obsolete <$header> in $file" fi } export -f check_includes obj=$1 header=$2 find src \( -name '*.h' -or -name '*.cpp' -or -name '*.hpp' \) -exec bash -c 'check_includes "$0" "$1" "$2"' "$obj" "$header" {} \; ``` ## How Has This Been Tested? Built code locally ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone
1 parent bc6360f commit f8befc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+47
-22
lines changed

src/bench/addrman.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <random.h>
88
#include <util/time.h>
99

10-
#include <optional>
1110
#include <vector>
1211

1312
/* A "source" is a source address from which we have received a bunch of other addresses. */

src/bitcoin-tx.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <functional>
2727
#include <memory>
28+
#include <optional>
2829
#include <stdio.h>
2930

3031
#include <stacktraces.h>

src/bitcoind.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <util/url.h>
2727

2828
#include <functional>
29-
#include <optional>
3029
#include <stdio.h>
3130

3231
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

src/chainparams.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <util/hash_type.h>
1616

1717
#include <memory>
18+
#include <optional>
1819
#include <string>
1920
#include <vector>
2021

src/coinjoin/client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#include <coinjoin/coinjoin.h>
1010
#include <util/translation.h>
1111

12-
#include <utility>
1312
#include <atomic>
13+
#include <deque>
14+
#include <utility>
1415

1516
class CDeterministicMN;
1617
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;

src/coinjoin/coinjoin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <util/translation.h>
1818
#include <version.h>
1919

20+
#include <atomic>
21+
#include <optional>
2022
#include <utility>
2123

2224
class CCoinJoin;

src/consensus/params.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <llmq/params.h>
1111

1212
#include <limits>
13-
#include <map>
1413

1514
namespace Consensus {
1615

src/dbwrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <memenv.h>
1414
#include <stdint.h>
1515
#include <algorithm>
16+
#include <optional>
1617

1718
class CBitcoinLevelDBLogger : public leveldb::Logger {
1819
public:

src/evo/cbtx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <primitives/transaction.h>
1010
#include <univalue.h>
1111

12+
#include <optional>
13+
1214
class BlockValidationState;
1315
class CBlock;
1416
class CBlockIndex;

src/evo/deterministicmns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <immer/map.hpp>
2121

22+
#include <atomic>
2223
#include <limits>
2324
#include <numeric>
2425
#include <unordered_map>

0 commit comments

Comments
 (0)