From 87ed42bed1c3f3a470cadbae8bfaf1e68577dc49 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Thu, 2 Jul 2026 11:00:09 -0500 Subject: [PATCH 1/2] Fix build-SITL-Mac VLA-folding-constant error in log.c _logBufferHex() sized a stack buffer using two `const size_t` locals (charsPerByte, maxBytes). In C, const-qualified objects are not integer constant expressions, so the array size expression was technically a variable-length array; recent AppleClang treats reliance on its extension that folds such expressions back to a constant as an error under -Werror -Wgnu-folding-constant, breaking build-SITL-Mac. Replace the const locals with a local enum, whose members are genuine integer constant expressions in C. The buffer size and behavior are unchanged (13 + 5*8 + 1 = 54 bytes either way). --- src/main/common/log.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/common/log.c b/src/main/common/log.c index c2cc30a3a48..d1d9ef1e6b0 100644 --- a/src/main/common/log.c +++ b/src/main/common/log.c @@ -205,8 +205,12 @@ void _logBufferHex(logTopic_e topic, unsigned level, const void *buffer, size_t { // Print lines of up to maxBytes bytes. We need 5 characters per byte // 0xAB[space|\n] - const size_t charsPerByte = 5; - const size_t maxBytes = 8; + // charsPerByte/maxBytes must be true compile-time constants (not `const` + // locals) so the buffer size below is a real constant expression, not a VLA. + enum { + charsPerByte = 5, + maxBytes = 8, + }; char buf[LOG_PREFIX_FORMATTED_SIZE + charsPerByte * maxBytes + 1]; // +1 for the null terminator size_t bufPos = LOG_PREFIX_FORMATTED_SIZE; const uint8_t *inputPtr = buffer; From b757e487121f21f70b18e70fb95b5b4fbecfdb0a Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Thu, 2 Jul 2026 12:18:53 -0500 Subject: [PATCH 2/2] Fix build-SITL-Mac VLA-folding-constant error in osd.c STATIC_ASSERT STATIC_ASSERT expands to a typedef of a char array sized by the condition, a common compile-time-assertion trick. This call site's condition compared GPS_DEGREES_DIVIDER (already 10000000L) against the floating-point literal 1e7. Per C11 6.6p6, integer constant expressions may not contain floating constants, so despite being trivially foldable, AppleClang's -Wgnu-folding-constant -Werror rejects it. Replace 1e7 with 10000000L to match GPS_DEGREES_DIVIDER's own literal form, making the condition a pure integer constant expression. No change to the assertion's truth value or any runtime behavior. --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 0bdb9e3375f..aa0a01ce71b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -841,7 +841,7 @@ static void osdFormatCoordinate(char *buff, char sym, int32_t val) int integerDigits = tfp_sprintf(buff + 1, (integerPart == 0 && val < 0) ? "-%d" : "%d", (int)integerPart); // We can show up to 7 digits in decimalPart. int32_t decimalPart = abs(val % (int)GPS_DEGREES_DIVIDER); - STATIC_ASSERT(GPS_DEGREES_DIVIDER == 1e7, adjust_max_decimal_digits); + STATIC_ASSERT(GPS_DEGREES_DIVIDER == 10000000L, adjust_max_decimal_digits); int decimalDigits; bool djiCompat = false; // Assume DJICOMPAT mode is no enabled