arduino-libraries / Arduino_JSON

Official JSON Library for Arduino
GNU Lesser General Public License v2.1
154 stars 60 forks source link

Error conflicting types #52

Closed videobuff closed 1 year ago

videobuff commented 1 year ago

At the moment, while using Arduino IDE 1.8.19, I get the following error in all my ESP32 DEVKIT projects where i use Arduin_JSON.

Even when trying the object example from the Arduino_JSON library it fails with this error.

Any help is very much appreciated...

/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:75:22: error: conflicting types for 'cJSON_GetStringValue'
 CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
                      ^~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:179:22: note: previous declaration of 'cJSON_GetStringValue' was here
 CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
                      ^~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:85:6: error: #error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
     #error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
      ^~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1911:20: error: conflicting types for 'cJSON_AddItemToArray'
 CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
                    ^~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:222:26: note: previous declaration of 'cJSON_AddItemToArray' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
                          ^~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1969:20: error: conflicting types for 'cJSON_AddItemToObject'
 CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
                    ^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:223:26: note: previous declaration of 'cJSON_AddItemToObject' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
                          ^~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1975:20: error: conflicting types for 'cJSON_AddItemToObjectCS'
 CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:227:26: note: previous declaration of 'cJSON_AddItemToObjectCS' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
                          ^~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1980:20: error: conflicting types for 'cJSON_AddItemReferenceToArray'
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:229:26: note: previous declaration of 'cJSON_AddItemReferenceToArray' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1990:20: error: conflicting types for 'cJSON_AddItemReferenceToObject'
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:230:26: note: previous declaration of 'cJSON_AddItemReferenceToObject' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:2178:20: error: conflicting types for 'cJSON_InsertItemInArray'
 CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:242:26: note: previous declaration of 'cJSON_InsertItemInArray' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
                          ^~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:2242:20: error: conflicting types for 'cJSON_ReplaceItemInArray'
 CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
                    ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:244:26: note: previous declaration of 'cJSON_ReplaceItemInArray' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
                          ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:2272:20: error: conflicting types for 'cJSON_ReplaceItemInObject'
 CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:245:26: note: previous declaration of 'cJSON_ReplaceItemInObject' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:2277:20: error: conflicting types for 'cJSON_ReplaceItemInObjectCaseSensitive'
 CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:246:26: note: previous declaration of 'cJSON_ReplaceItemInObjectCaseSensitive' was here
 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:2550:23: error: conflicting types for 'cJSON_CreateStringArray'
 CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
                       ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Users/erikschott/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:219:23: note: previous declaration of 'cJSON_CreateStringArray' was here
 CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
                       ^~~~~~~~~~~~~~~~~~~~~~~
exit status 1
Fout bij het compileren voor board ESP32 Dev Module
videobuff commented 1 year ago

Probably solved. Removed all (leftover) instances of thje libary from my machine, then reinstalled the library. Still testing it

per1234 commented 1 year ago

Thanks for your report @videobuff! There was a previous report of the same problem here:

https://github.com/arduino-libraries/Arduino_JSON/issues/48

As I explained there, it seems to be caused by a rare interaction between the Library Manager installation/update process and the operating system or iCloud. As you found, the workaround is to remove and then reinstall the library. Since you already resolved the problem on your system, and since it doesn't seem to be caused by anything in the codebase hosted in this repository, I'll go ahead and close this.

I do think it is quite interesting that we received two reports for this library. I have been watching for reports of this type of issue (duplicated files after a Library Manager operation) and logging all reports and so far I've only seen 6 total. It is highly unlikely that 1/3 of the reports I encountered would be from users of this specific library if the problem was equally likely to occur with any of the >5k libraries in Library Manager (many of which are more actively installed/updated than this one).