From a0a0ebf69e8626eae33fd3b69b4e2897a24da2b6 Mon Sep 17 00:00:00 2001 From: Balduin Date: Mon, 31 Aug 2026 13:53:37 +0200 Subject: [PATCH] refactor(modes): deduplicate nav_state_names table across translation units nav_state_names is a namespace-scope const array defined in a header, which gives it internal linkage: every translation unit including ui.hpp carried its own copy of the 124-byte pointer table. Declare it inline (C++17) so the linker keeps a single shared instance. px4_fmu-v6x_default flash: -376 B --- src/lib/modes/ui.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/modes/ui.hpp b/src/lib/modes/ui.hpp index 43f75e64a4c..b4f7ef4ae16 100644 --- a/src/lib/modes/ui.hpp +++ b/src/lib/modes/ui.hpp @@ -69,7 +69,9 @@ static inline uint32_t getValidNavStates() static_assert(vehicle_status_s::NAVIGATION_STATE_MAX == 31, "update valid nav states"); } -const char *const nav_state_names[vehicle_status_s::NAVIGATION_STATE_MAX] = { +// inline: this header is included from several translation units, and a namespace-scope const +// array has internal linkage, so without it each of them gets its own copy of the table +inline const char *const nav_state_names[vehicle_status_s::NAVIGATION_STATE_MAX] = { "Manual", "Altitude", "Position",