mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-23 10:18:30 +08:00
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
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user