arduino-libraries/Arduino_JSON

conflicting types for 'cJSON_GetStringValue'

Closed this issue · 1 comments

kxlu commented

Upgraded Arduino_JSON to 0.2.0 and got the following compilation error. Please help.

/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:75:22: error: conflicting types for 'cJSON_GetStringValue'
   75 | CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
      |                      ^~~~~~~~~~~~~~~~~~~~
In file included from /Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:58:
/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON.h:179:22: note: previous declaration of 'cJSON_GetStringValue' was here
  179 | CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
      |                      ^~~~~~~~~~~~~~~~~~~~
/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.
   85 |     #error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
      |      ^~~~~
/Documents/Arduino/libraries/Arduino_JSON/src/cjson/cJSON 2.c:1911:20: error: conflicting types for 'cJSON_AddItemToArray'
 1911 | CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)

Hi @kxlu. The problem is that two copies of the library source file were created. Note that one is named cJSON.h and the other cJSON 2.h.

We received a few other reports of this problem. A colleague investigated and determined the copies of files/folders with the 2 suffix are generated by iCloud during a library update.

The easiest solution is to uninstall and then reinstall the affected library. I'll provide instructions. These instructions are for the Arduino IDE 2.x interface, but they should be generally applicable to Arduino IDE 1.x as well if you aren't using one of the 2.x IDE versions:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
  2. In the "Filter your search" field, type Arduino_JSON
  3. Scroll down through the list of libraries until you see the "Arduino_JSON" entry.
  4. You will see an "INSTALLED" label near the top right corner of the library entry. Hover the mouse pointer over that label.
  5. The label will now turn into an "UNINSTALL" button. Click that button.
    An "Uninstall" dialog asking whether you want to uninstall the library will open.
  6. Click the "YES" button in the "Uninstall" dialog.
  7. Wait for the uninstall process to finish.
  8. Select the newest version from the dropdown version menu at the bottom of the "Arduino_JSON" entry.
  9. Click the "INSTALL" button at the bottom of the "Arduino_JSON" entry.
  10. Wait for the installation to finish.

Since the problem is not related to the codebase hosted in this repository, I'll close the issue now. If you have any questions or problems using the library, you are welcome to post on the Arduino Forum. I'm sure we can help you out over there:

https://forum.arduino.cc/