[Gdal-dev] gdalwarp tutorial VS2003 compile error

Mateusz Loskot mateusz at loskot.net
Mon Feb 26 16:35:20 EST 2007


Huajun Zhang wrote:
> 
> The code is as following:
> 
> // Get Source coordinate system. const char *pszSrcWKT, *pszDstWKT =
> NULL;

Here, you're declaring *const* pointers to char.

> oSRS.exportToWkt( &pszDstWKT );

Here, you pass const pointer where non-const is expected.
Also, it's a good idea to check the manual to see what types are expected:

http://www.gdal.org/ogr/classOGRSpatialReference.html#8b8123ea88b3e2ffb082e5eec06d52d5

Because of C/C++ strong type safety, the const qualifier is not removed
implicitly.

You have two choices:

1) Declare the pszDstWKT as a non-const pointer:

char* pszDstWKT = NULL;

2) Leave the pszDstWkt declared as const char* and ask the compiler to
remove the const qualifier:

oSRS.exportToWkt( const_cast<char**>(pszDstWKT) );

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Gdal-dev mailing list