24 | | Reported by EvenR. Need an example failure. |
| 25 | Reported by EvenR. |
| 26 | |
| 27 | Example code that is failing (from Ubuntu 14.04 @ r34748): |
| 28 | |
| 29 | {{{#!c |
| 30 | /* avc_e00read.c */ |
| 31 | static int _AVCE00ReadBuildSqueleton(AVCE00ReadPtr psInfo, |
| 32 | char **papszCoverDir) |
| 33 | { |
| 34 | |
| 35 | /* ... */ |
| 36 | |
| 37 | szFname = (psInfo->eCoverType==AVCCoverV7 || |
| 38 | psInfo->eCoverType==AVCCoverPC2 ) ? "arc.adf": "arc"; |
| 39 | if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && |
| 40 | (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, |
| 41 | psInfo->eCoverType, AVCFileARC, |
| 42 | psInfo->psDBCSInfo)) != NULL) |
| 43 | { |
| 44 | }}} |
| 45 | |
| 46 | Fails like: |
| 47 | |
| 48 | {{{ |
| 49 | avc_e00read.c: In function '_AVCE00ReadBuildSqueleton': |
| 50 | avc_e00read.c:1040:5: warning: passing argument 1 of 'CSLFindString' from incompatible pointer type [enabled by default] |
| 51 | if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && |
| 52 | ^ |
| 53 | In file included from avc.h:119:0, |
| 54 | from avc_e00read.c:129: |
| 55 | /home/schwehr/src/gdal/gdal/port/cpl_string.h:106:13: note: expected 'const char * const*' but argument is of type 'char **' |
| 56 | int CPL_DLL CSLFindString( const char * const *, const char * ); |
| 57 | }}} |
| 58 | |
| 59 | Could cast in C: |
| 60 | {{{#!c |
| 61 | szFname = (psInfo->eCoverType==AVCCoverV7 || |
| 62 | psInfo->eCoverType==AVCCoverPC2 ) ? "arc.adf": "arc"; |
| 63 | if ( (iFile=CSLFindString((const char * const *)papszCoverDir, szFname)) != -1 && |
| 64 | (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, |
| 65 | psInfo->eCoverType, AVCFileARC, |
| 66 | psInfo->psDBCSInfo)) != NULL) |
| 67 | { |
| 68 | |
| 69 | }}} |
| 70 | |
| 71 | Or modify cpl_string.h to present non-const to C. (least bad so far) |
| 72 | {{{#!c++ |
| 73 | #ifdef __cplusplus |
| 74 | int CPL_DLL CSLFindString( const char * const *, const char * ); |
| 75 | int CPL_DLL CSLFindStringCaseSensitive( const char * const *, const char * ); |
| 76 | int CPL_DLL CSLPartialFindString( const char * const *papszHaystack, |
| 77 | const char * pszNeedle ); |
| 78 | #else |
| 79 | // Present non-const to C code that does not like passing non-const to const. |
| 80 | int CPL_DLL CSLFindString( char **, const char * ); |
| 81 | int CPL_DLL CSLFindStringCaseSensitive( char **, const char * ); |
| 82 | int CPL_DLL CSLPartialFindString( char **papszHaystack, |
| 83 | const char * pszNeedle ); |
| 84 | #endif |
| 85 | }}} |