فهرست منبع

Temporarily disable warning when const is cast away.

There was a long running discussion here
https://github.com/DaveGamble/cJSON/pull/80 how to provide const
correctness for users of cJSON.

To avoid breaking changes for users of cJSON v1 it was decided to
disable this warning.

pragma was tested with gcc 5.4.0/6.2.1 and clang 3.8/3.9.
Stephan 8 سال پیش
والد
کامیت
e69db83de5
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      cJSON.c

+ 3 - 0
cJSON.c

@@ -1756,7 +1756,10 @@ void   cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
     {
     {
         cJSON_free(item->string);
         cJSON_free(item->string);
     }
     }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
     item->string = (char*)string;
     item->string = (char*)string;
+#pragma GCC diagnostic pop
     item->type |= cJSON_StringIsConst;
     item->type |= cJSON_StringIsConst;
     cJSON_AddItemToArray(object, item);
     cJSON_AddItemToArray(object, item);
 }
 }