From 51d36dfd076a98cd761ab312ab10792725ed7a29 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 20 Jul 2026 12:23:51 +0100 Subject: [PATCH] qt: Fix `-Wsfinae-incomplete` warnings when building with GCC 16.x According to the CMake documentation for `AUTOMOC`, all `moc` output files that are not included in a source file are aggregated into the CMake-generated `/mocs_compilation.cpp`, which is added to the target's sources. Within that single translation unit, `moc`-generated code checks the completeness of a signal or slot parameter type while it is still only forward-declared, and the type is completed later, when a subsequently included `moc_*.cpp` file pulls in the header that defines it. GCC 16.x diagnoses this pattern with the `-Wsfinae-incomplete` warning, which is enabled by default. Including the `moc` output files at the end of the corresponding source files excludes them from `mocs_compilation.cpp`, so each one is compiled in a translation unit where the relevant types are complete. Additionally: 1. Some of the `BitcoinGUI` class's private members are gated with `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings when building with `-DENABLE_WALLET=OFF`. 2. `test/lint/lint-includes.py` is adjusted to allow new `#include` statements. --- src/qt/bitcoingui.cpp | 2 ++ src/qt/bitcoingui.h | 8 ++++++-- src/qt/qvalidatedlineedit.cpp | 2 ++ src/qt/sendcoinsentry.cpp | 2 ++ test/lint/lint-includes.py | 6 +++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 9d3f7ad639f..5f169a951c4 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1721,3 +1721,5 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action) optionsModel->setDisplayUnit(action->data()); } } + +#include diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 2322860a710..babb8961622 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -114,7 +114,9 @@ protected: private: interfaces::Node& m_node; +#ifdef ENABLE_WALLET WalletController* m_wallet_controller{nullptr}; +#endif // ENABLE_WALLET std::unique_ptr m_handler_message_box; std::unique_ptr m_handler_question; ClientModel* clientModel = nullptr; @@ -158,15 +160,17 @@ private: QAction* m_restore_wallet_action{nullptr}; QAction* m_close_wallet_action{nullptr}; QAction* m_close_all_wallets_action{nullptr}; +#ifdef ENABLE_WALLET QAction* m_wallet_selector_label_action = nullptr; QAction* m_wallet_selector_action = nullptr; +#endif // ENABLE_WALLET QAction* m_mask_values_action{nullptr}; QAction* m_migrate_wallet_action{nullptr}; QMenu* m_migrate_wallet_menu{nullptr}; - +#ifdef ENABLE_WALLET QLabel *m_wallet_selector_label = nullptr; QComboBox* m_wallet_selector = nullptr; - +#endif // ENABLE_WALLET QSystemTrayIcon* trayIcon = nullptr; const std::unique_ptr trayIconMenu; Notificator* notificator = nullptr; diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp index 026ff8d0517..665d453b48f 100644 --- a/src/qt/qvalidatedlineedit.cpp +++ b/src/qt/qvalidatedlineedit.cpp @@ -126,3 +126,5 @@ bool QValidatedLineEdit::isValid() return valid; } + +#include diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 679457262dd..aa4c07dc4b0 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -238,3 +238,5 @@ bool SendCoinsEntry::updateLabel(const QString &address) return false; } + +#include diff --git a/test/lint/lint-includes.py b/test/lint/lint-includes.py index 2e8417ea734..328946d83b5 100755 --- a/test/lint/lint-includes.py +++ b/test/lint/lint-includes.py @@ -70,7 +70,11 @@ def find_included_cpps(): if e.returncode > 1: raise e - return included_cpps + # Exception: `#include ` statements in src/qt source files are permitted. + # See: + # - https://doc.qt.io/qt-6/moc.html + # - https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html + return [i for i in included_cpps if not re.match(r"src/qt/[^:]+\.cpp:#include :]+\.cpp>$", i)] def find_extra_boosts():