Opened 8 years ago

Last modified 8 years ago

#6602 closed defect

C does not like const of CSLFindString as done in r34749 — at Version 1

Reported by: Kurt Schwehr Owned by: Kurt Schwehr
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: blocker Keywords:
Cc:

Description (last modified by Kurt Schwehr)

e.g. https://travis-ci.org/rouault/gdal_coverage/builds/146409340

gcc -I/home/travis/build/rouault/gdal_coverage/gdal/port -I/home/travis/build/rouault/gdal_coverage/gdal/gcore -I/home/travis/build/rouault/gdal_coverage/gdal/alg -I/home/travis/build/rouault/gdal_coverage/gdal/ogr -I/home/travis/build/rouault/gdal_coverage/gdal/ogr/ogrsf_frmts -I/home/travis/build/rouault/gdal_coverage/gdal/gnm -I/home/travis/build/rouault/gdal_coverage/gdal/apps -fPIC  -g -DDEBUG -ftrapv  -Wall -Wdeclaration-after-statement -Wextra -Winit-self -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wformat -Werror=format-security -Wno-format-nonliteral -Wlogical-op -Wshadow -Werror=vla -Wdeclaration-after-statement -DDEBUG_BOOL -Wextra -Werror -I../shape -I.. -I../..  -DOGR_ENABLED -D_REENTRANT  -I/home/travis/build/rouault/gdal_coverage/gdal/port -I/usr/local/include -I/usr/include  -DGDAL_COMPILATION -c -o ../o/avc_e00read.o avc_e00read.c
avc_e00read.c: In function ‘_AVCE00ReadBuildSqueleton’:
avc_e00read.c:1040:5: error: passing argument 1 of ‘CSLFindString’ from incompatible pointer type [-Werror]
/home/travis/build/rouault/gdal_coverage/gdal/port/cpl_string.h:106:13: note: expected ‘const char * const*’ but argument is of type ‘char **’
avc_e00read.c:1061:5: error: passing argument 1 of ‘CSLFindString’ from incompatible pointer type [-Werror]
/home/travis/build/rouault/gdal_coverage/gdal/port/cpl_string.h:106:13: note: expected ‘const char * const*’ but argument is of type ‘char **’
...
cc1: all warnings being treated as errors

What exactly is this complaining about?

Possible solutions (will they even work)?

  • Separate out a new const function and have the old call the new. CSLFindStringConst or CSLFindString2 or CSLFindStringEx
  • Provide a different signature for C without the const (if it will link)
  • Have a define like GDAL_CONST_STRICT to provide a more cost API for places that want it
  • Revert and give up in despair
  • Can we cast in the C code?
  • Or?

Reported by EvenR. Need an example failure.

Change History (1)

comment:1 by Kurt Schwehr, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.