Opened 3 years ago

Closed 3 years ago

#5449 closed defect (fixed)

failure to build against external json-c 0.12

Reported by: landry Owned by: warmerdam
Priority: normal Milestone: 1.11.1
Component: default Version: 1.11.0
Severity: normal Keywords:
Cc:

Description (last modified by landry)

json-c 0.12 removed some external symbols, mostly the json_tokener_errors string array, which is now replaced by a json_tokener_error_desc() function taking an offset. (they also deprecated 'json_object_object_get' in favour of json_object_object_get_ex but that's only a #warning)

This breaks the build using --with-libjson-c= pointing to a 0.12 install... i see two potential fixes:

  • if not existing, #define json_tokener_errors to a call to json_tokener_error_desc() - i doubt that's feasible with a macro.
  • add some #ifdef spaghetti based on JSON_C_MINOR_VERSION, calling one or the other if > 12.
  • for a second i thought it would be possible to use the #define error_description(error) macro defined in json-c/bits.h, but it is still defined to (json_tokener_errors[error]) in 0.12 (which is wrong on so many levels....)

If needs be, i can provide a patch for whichever version you prefer..

json_tokener_errors is used in the following files:

./gdal-1.11.0/frmts/mbtiles/mbtilesdataset.cpp
./gdal-1.11.0/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp
./gdal-1.11.0/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp
./gdal-1.11.0/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp
./gdal-1.11.0/ogr/ogrsf_frmts/couchdb/ogrcouchdbdatasource.cpp
./gdal-1.11.0/ogr/ogrsf_frmts/gme/ogrgmejson.cpp

Attachments (1)

fix-5449.diff (4.6 KB) - added by landry 3 years ago.
replace all occurences of deprecated json_tokener_errors[jstok->err] by json_tokener_error_desc(jstok->err)

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by landry

Description: modified (diff)

comment:2 Changed 3 years ago by landry

And for the record, json_tokener_error_desc() has been available since json-c 0.10, so maybe we can safely assume it's present if we require this version..

comment:3 Changed 3 years ago by Even Rouault

If you can provide a patch that would be much appreciated. The requirement since GDAL 1.11 is json-c >= 0.11

Changed 3 years ago by landry

Attachment: fix-5449.diff added

replace all occurences of deprecated json_tokener_errors[jstok->err] by json_tokener_error_desc(jstok->err)

comment:4 Changed 3 years ago by Even Rouault

Milestone: 1.11.1
Resolution: fixed
Status: newclosed

trunk r27267, branches/1.11 r27268 : "Fix compilation errors with json-c 0.12 (patch by landry, #5449)"

Note: See TracTickets for help on using tickets.