[Gdal-dev] VC++ Wrapper

Matthew Hanson mhanson at photon.com
Thu Oct 14 14:29:23 EDT 2004


Ok, I was looking through the OSSIM code and it looks like it also uses the
C API instead of the C++ API.  
So basically, you recommend developers to use the C API over C++.  In what
situations would you recommend an application to use the native C++ API
directly?

Also, I'm trying to figure out how the code is put together and I see
CPL_DLL in the function declarations for GDAL, and is OSSIM.  I'm not really
sure what this does (though I do understand CPL is used to make GDAL
portable to different platforms).
Could you briefly comment on how CPL is used in GDAL and the CPL_DLL syntax
in function and class declarations?

Thanks!

matt



> -----Original Message-----
> From: Frank Warmerdam [mailto:warmerdam at pobox.com]
> Sent: Thursday, October 14, 2004 12:53 PM
> To: Matthew Hanson
> Cc: gdal-dev at xserve.flids.com
> Subject: Re: [Gdal-dev] VC++ Wrapper
> 
> Matthew Hanson wrote:
> > Hi,
> >
> > I'm working on a managed wrapper for GDAL to create a .NET assembly.
> >
> > I just wanted to clarify a few things.  The C++ API (in gdal_priv.h)
> looks
> > like it's a C++ wrapper to the underlying C code.  Is this true?  If so,
> I
> > think I'd rather interface with the C API then end up having a wrapper
> > around a wrapper.   Are there any benefits to using the C++ API?
> 
> Matt,
> 
> The C++ API is actually the "real" implementation.  The C API is just
> thin wrappers around it.  Nevertheless, I encourage you to target the C
> API
> because it is much less "fragile" than the C++ API.  It becomes almost
> impossible to substitute new versions of GDAL DLLs into an application
> that
> calls the C++ API directly because of minor changes in method signatures
> (like const correctness changes) or any change in the internal layout of
> C++ objects (add new data members for instance).
> 
> So my experience has been that wrappers and applications written against
> the C API are less tightly linked to a specific version of GDAL than C++
> API callers.
> 
> > Also, there looks like there's some parts of GDAL (like the warp API)
> that
> > are only in C++.  In this case I'd have to use the C++ API.  Are there
> any
> > other parts of GDAL that only have a C++ API?
> 
> Alternatively, you can point out these issues to me, and I can look into
> preparing C wrappers.  My intent with the warp api would be that a C API
> should
> exist for applications that want to instantiate and invoke a
> GDALWarpOperation
> from an input GDALWarpOptions.  The GDALWarpOptions is deliberately kept
> as a
> simple C structure so it can be created and manipulated smoothly in C.
> However, it has alot of callback functions which might be tricky to
> implement
> in a .NET binding.  I have not tried to implement the full warp API in
> Python
> for instance.
> 
> Best regards,
> --
> ---------------------------------------+----------------------------------
> ----
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list