OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.91k stars 2.55k forks source link

OGRwkbGeometryType using non ISO C compliant values #2322

Closed caiohamamura closed 2 weeks ago

caiohamamura commented 4 years ago

Expected behavior and actual behavior.

I was using gdal library in my source code and compiling it with -Wpedantic and came across an issue when including ogr_core.h.

In file included from /usr/include/gdal/ogr_srs_api.h:35,
                 from gedisimulator/gediIO.c:17:
/usr/include/gdal/ogr_core.h:399:19: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  399 |     wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */
      |                   ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:400:24: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  400 |     wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */
      |                        ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:401:21: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  401 |     wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */
      |                     ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:402:24: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  402 |     wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */
      |                        ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:403:29: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  403 |     wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */
      |                             ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:404:26: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  404 |     wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */
      |                          ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:405:32: warning: ISO C restricts enumerator values to range of ‘int’ [-Wpedantic]
  405 |     wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */

Steps to reproduce the problem.

sudo apt-get install libgdal-dev -y
echo "#include <ogr_core.h>" > test.c
gcc -c test.c -Wpedantic $(gdal-config --cflags)

Operating system

Ubuntu 18.04.4 LTS Bionic 64 bit

GDAL version and provenance

2.2.3 version from ubuntu official repository

rouault commented 4 years ago

Unlikely to be changed in a near/medium term future given this would be an ABI break of the C API

nilason commented 9 months ago

Seems to me to be “solved” with the C23 standard:

All enumerations have an underlying type. The underlying type can be explicitly specified using an enum type specifier and is its fixed underlying type. If it is not explicitly specified, the underlying type is the enumeration’s compatible type, which is either char or a standard or extended signed or unsigned integer type.

(6.7.2.2 Enumeration specifiers (p: 107-112))