[gdal-dev] Patch to improve libjpeg compatibility on gdal 1.11

David Weiß David.Weiss at ptvgroup.com
Wed Feb 18 04:08:38 PST 2015


> Hum, I've tried to replicate a minimalistic version of libjpeg_io.cpp:
> 
> 
> """
> namespace PCIDSK
> {
> };
> 
> #include "cpl_port.h"
> 
> using namespace PCIDSK;
> 
> extern "C" {
> typedef enum { FALSE = 0, TRUE = 1 } boolean; } """
> 
> The above fails to compile because cpl_port.h contains:
> """
> #ifndef FALSE
> #  define FALSE 0
> #endif
> 
> #ifndef TRUE
> #  define TRUE  1
> #endif
> """

The
#include "cpl_port.h"
has not been present in gdal 1.11.1 release, where I first noticed the problem.

Commit 27739 added the include which fixed the problem, because now when jmorecfg.h is included, TRUE is already defined thus triggering the definition of boolean as int and not enum.

Only noticed after trying to reproduce the problem in a clean environment :)
Should have checked for that before submitting a useless patch.

> I'm also not completely convinced by the fact that "typedef boolean as enum
> with values TRUE and FALSE, which do not propagate into other namespace"
> 
> The following small experiment (with "include cpl_port.h" commented)
> compiles
> fine :
> 
> """
> namespace PCIDSK
> {
>     int foo();
> };
> 
> //#include "cpl_port.h"
> 
> using namespace PCIDSK;
> 
> extern "C" {
> typedef enum { FALSE = 0, TRUE = 1 } boolean;
> }
> 
> int PCIDSK::foo()
> {
>     return TRUE;
> }
> """
> 
> I must certainly miss something...

Weird.. at least in VS2010 it didn't work.
I can reproduce it, if I replace
#include "cpl_port.h"
with
#define CPL_UNUSED
(because that will cause other errors..)

cl   /nologo /MD /EHsc /Ox /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG /W4 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4018 /wd4389 /DHAVE_SSE_AT_COMPILE_TIME -I..\..\port -I..\..\ogr -I..\..\gcore  -I..\..\alg -I..\..\ogr\ogrsf_frmts  -DOGR_ENABLED  -Isdk -DPCIDSK_INTERNAL -DHAVE_LIBJPEG -I"S:\ext\repo\libjpeg-win-x64-vc10\include" /c sdk\core\libjpeg_io.cpp /Fosdk\core\libjpeg_io.obj
libjpeg_io.cpp
sdk\core\libjpeg_io.cpp(109) : error C2065: 'TRUE' : undeclared identifier
sdk\core\libjpeg_io.cpp(177) : error C2065: 'TRUE' : undeclared identifier
sdk\core\libjpeg_io.cpp(178) : error C2065: 'TRUE' : undeclared identifier
sdk\core\libjpeg_io.cpp(195) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

> 
> Even
> 
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com


More information about the gdal-dev mailing list