From ad50ada234774a7c5206a0b2bc607135aac57538 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Tue, 8 Sep 2026 11:44:56 +0700 Subject: [PATCH] fix(esp_common): detect nonstring attribute with __has_attribute --- components/esp_common/include/esp_attr.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp_common/include/esp_attr.h b/components/esp_common/include/esp_attr.h index 8d78cfa9be6..1b38fbdbafe 100644 --- a/components/esp_common/include/esp_attr.h +++ b/components/esp_common/include/esp_attr.h @@ -181,10 +181,12 @@ extern "C" { // Forces to not inline function #define NOINLINE_ATTR __attribute__((noinline)) -#if !defined(__clang__) && __GNUC__ >= 15 -// Marks a character array as not null-terminated to avoid string-related optimizations or warnings -#define NONSTRING_ATTR __attribute__ ((nonstring)) -#else +#if defined(__has_attribute) +#if __has_attribute(nonstring) +#define NONSTRING_ATTR __attribute__((nonstring)) +#endif +#endif +#ifndef NONSTRING_ATTR #define NONSTRING_ATTR #endif