Keep the Qt keyword macros in the test from failing -Wunused-macros

Clang (-Werror) rejected the macros that the test defines but the library
must not use, and clang-tidy asked for parentheses around the arguments
of the Q_FOREACH imitation, where the variable is a declaration.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-17 20:48:15 +02:00
1 parent 22497c7128
commit 77052ec0f2
1 file changed
+6 -1
+6 -1
View File
@@ -14,7 +14,7 @@
#define slots
#define signals public
#define emit
#define Q_FOREACH(variable, container) for (variable : container)
#define Q_FOREACH(variable, container) for (variable : container) // NOLINT(bugprone-macro-parentheses): variable is a declaration, as in Qt
#define foreach Q_FOREACH
#define forever for (;;)
@@ -60,3 +60,8 @@ TEST_CASE("Qt keyword macros")
CHECK(source.patch(json::diff(source, target)) == target);
}
}
// testing for the macros also keeps -Wunused-macros from rejecting them
#if !defined(slots) || !defined(signals) || !defined(emit) || !defined(Q_FOREACH) || !defined(foreach) || !defined(forever)
#error "the Qt keyword macros must stay defined for the tests above"
#endif