Skip to content

Commit 36a90d6

Browse files
mbernasocchimhugent
authored andcommittedMar 12, 2013
fix typedef void *OGR issues
1 parent a56c957 commit 36a90d6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎src/core/qgsvectorfilewriter.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626

2727
#include <QPair>
2828

29+
#ifdef DEBUG
30+
typedef struct OGRDataSourceHS *OGRDataSourceH;
31+
typedef struct OGRLayerHS *OGRLayerH;
32+
typedef struct OGRGeometryHS *OGRGeometryH;
33+
#else
2934
typedef void *OGRDataSourceH;
3035
typedef void *OGRLayerH;
3136
typedef void *OGRGeometryH;
3237
typedef void *OGRFeatureH;
38+
#endif
39+
3340

3441
class QgsSymbolLayerV2;
3542
class QTextCodec;

‎src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ QgsRasterInterface * QgsGdalProvider::clone() const
159159

160160
bool QgsGdalProvider::crsFromWkt( const char *wkt )
161161
{
162-
void *hCRS = OSRNewSpatialReference( NULL );
162+
163+
#ifdef DEBUG
164+
struct OGRSpatialReferenceHS *hCRS = OSRNewSpatialReference( NULL );
165+
#else
166+
void *hCRS = OSRNewSpatialReference( NULL );
167+
#endif
163168

164169
if ( OSRImportFromWkt( hCRS, ( char ** ) &wkt ) == OGRERR_NONE )
165170
{

5 commit comments

Comments
 (5)

rouault commented on Mar 12, 2013

@rouault
Contributor

[21:51] * EvenR surprised to see OGR typedefs being redefined in QGIS files ! Why not including OGR headers ??
[21:51] #include "ogr_api.h" et #include "ogr_srs_api.h" should do it
[21:52] that would make the #ifdef DEBUG #else stuff non necessary

rouault commented on Mar 12, 2013

@rouault
Contributor

the

void* hCRS = OSRNewSpatialReference( NULL );

line shoud be just replaced by :
OGRSpatialReferenceH hCRS = OSRNewSpatialReference( NULL );

would work in DEBUG and non DEBUG mode

mhugent commented on Mar 13, 2013

@mhugent
Contributor

Right, for gdalprovider, it is better to use OGRSpatialReferenceH directly.
In qgsvectorfilewriter.h, we cannot include ogr headers because there are problems compiling the python bindings if the ogr data structures are visible.

rouault commented on Mar 13, 2013

@rouault
Contributor

mhugent commented on Mar 14, 2013

@mhugent
Contributor

Actually it seems to compile if I just remove the typedef section... Don't know what the reason for the typedefs was then (it seems to come from the c-api port five years ago)

Please sign in to comment.