From aed519df8d29a96ee1bd4a8bef7920aae384f188 Mon Sep 17 00:00:00 2001 From: hanjinpeng Date: Thu, 17 Sep 2026 13:32:22 -0400 Subject: [PATCH] Suppress -Wcast-qual in cast_away_const for clang without __GNUC__, fixes #1062 The diagnostic push/pop around cast_away_const() is enabled for clang, but the "ignored" pragma in between was only enabled for __GNUC__. clang-cl on Windows doesn't define __GNUC__, so builds with -Wcast-qual -Werror failed. This can be reproduced on Linux with 'clang -fgnuc-version=0 -std=c89 -Wcast-qual -Werror -c cJSON.c'. --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 88c2d95b..71011806 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2066,7 +2066,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) #if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) #pragma GCC diagnostic push #endif -#ifdef __GNUC__ +#if defined(__clang__) || defined(__GNUC__) #pragma GCC diagnostic ignored "-Wcast-qual" #endif /* helper function to cast away const */