Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix typedef void *OGR issues
  • Loading branch information
mbernasocchi authored and mhugent committed Mar 12, 2013
1 parent a56c957 commit 36a90d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/core/qgsvectorfilewriter.h
Expand Up @@ -26,10 +26,17 @@

#include <QPair>

#ifdef DEBUG
typedef struct OGRDataSourceHS *OGRDataSourceH;
typedef struct OGRLayerHS *OGRLayerH;
typedef struct OGRGeometryHS *OGRGeometryH;
#else
typedef void *OGRDataSourceH;
typedef void *OGRLayerH;
typedef void *OGRGeometryH;
typedef void *OGRFeatureH;
#endif


class QgsSymbolLayerV2;
class QTextCodec;
Expand Down
7 changes: 6 additions & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -159,7 +159,12 @@ QgsRasterInterface * QgsGdalProvider::clone() const

bool QgsGdalProvider::crsFromWkt( const char *wkt )
{
void *hCRS = OSRNewSpatialReference( NULL );

#ifdef DEBUG
struct OGRSpatialReferenceHS *hCRS = OSRNewSpatialReference( NULL );
#else
void *hCRS = OSRNewSpatialReference( NULL );
#endif

if ( OSRImportFromWkt( hCRS, ( char ** ) &wkt ) == OGRERR_NONE )
{
Expand Down

5 comments on commit 36a90d6

@rouault
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the

void* hCRS = OSRNewSpatialReference( NULL );

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

would work in DEBUG and non DEBUG mode

@mhugent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@rouault rouault commented on 36a90d6 Mar 13, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhugent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.