Skip to content

Unable to compile with gcc 4.4.7 #126

Closed
@carlosabalde

Description

@carlosabalde

It seems gcc 4.4.7 (CentOS 6.6) does not support diagnostic inside functions:

cJSON.c: In function 'cJSON_AddItemToObjectCS':
cJSON.c:1594: error: #pragma GCC diagnostic not allowed inside functions
cJSON.c:1595: error: #pragma GCC diagnostic not allowed inside functions
cJSON.c:1597: error: #pragma GCC diagnostic not allowed inside functions

Not 100% sure why -Wcast-qual is being ignored here, but I think one possible solution would be:

+#if defined (__clang__) || ((__GNUC__)  && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
     item->string = (char*)string;
+#if defined (__clang__) || ((__GNUC__)  && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
 #pragma GCC diagnostic pop
+#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions