gdal icon indicating copy to clipboard operation
gdal copied to clipboard

OGRwkbGeometryType using non ISO C compliant values

Open caiohamamura opened this issue 5 years ago • 2 comments

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

caiohamamura avatar Mar 16 '20 14:03 caiohamamura

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

rouault avatar Mar 16 '20 15:03 rouault

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))

nilason avatar Jan 22 '24 22:01 nilason