qt: Fix `-Wsfinae-incomplete` warnings when building with GCC 16.x
What changed, and why it matters
This is a build-system cleanup for the Bitcoin Core graphical wallet. It silences new compiler warnings that appear with GCC 16.x by changing how Qt's meta-object compiler output is included, and it hides some wallet-only user-interface fields when the wallet is disabled at compile time. There is no security bug being fixed and no behavior change for end users.
No security action required; treat as a normal build-hygiene change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit addresses a GCC 16.x -Wsfinae-incomplete warning caused by AUTOMOC’s mocs_compilation.cpp aggregating moc_*.cpp files where signal/slot parameter types are forward-declared at the point of SFINAE checks. The fix explicitly includes moc_bitcoingui.cpp, moc_qvalidatedlineedit.cpp, and moc_sendcoinsentry.cpp at the bottom of their corresponding .cpp files, removing them from the aggregated compilation unit. It also gates several BitcoinGUI wallet-only private members with #ifdef ENABLE_WALLET to avoid -Wunused-private-field when ENABLE_WALLET=OFF, and updates test/lint/lint-includes.py to permit the new #include <moc_*.cpp> pattern.
Changed components
src/qt/bitcoingui.cppsrc/qt/bitcoingui.hsrc/qt/qvalidatedlineedit.cppsrc/qt/sendcoinsentry.cpptest/lint/lint-includes.pyInspect captured patch +17 / −3
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 9d3f7ad6..5f169a95 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 <moc_bitcoingui.cpp>
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 2322860a..babb8961 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<interfaces::Handler> m_handler_message_box;
std::unique_ptr<interfaces::Handler> 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<QMenu> trayIconMenu;
Notificator* notificator = nullptr;
diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp
index 026ff8d0..665d453b 100644
--- a/src/qt/qvalidatedlineedit.cpp
+++ b/src/qt/qvalidatedlineedit.cpp
@@ -126,3 +126,5 @@ bool QValidatedLineEdit::isValid()
return valid;
}
+
+#include <moc_qvalidatedlineedit.cpp>
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 67945726..aa4c07dc 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -238,3 +238,5 @@ bool SendCoinsEntry::updateLabel(const QString &address)
return false;
}
+
+#include <moc_sendcoinsentry.cpp>
diff --git a/test/lint/lint-includes.py b/test/lint/lint-includes.py
index 2e8417ea..328946d8 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 <moc_*.cpp>` 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 <moc_[^<>:]+\.cpp>$", i)]
def find_extra_boosts():
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.