[gdal-dev] SHP support in GDAL vs. GDAL-OGR

Frank Warmerdam warmerdam at p...
Tue Jan 15 09:58:14 EST 2002


Ben Discoe wrote:

> I guess the only complete solution here would be to have two macros, e.g.
> SHPAPI_CALL1, SHPAPI_CALL2 which would come before and after the asterisk.
> Not very pretty, but it would handle all cases. If you'd like me to do that
> and submit it, i'd be glad to.


Ben,

Thanks for rediscovering this stuff for me. To avoid this level of
pain in the future I have added the following comments to shapefil.h.
I have also modified the makefile.vc in gdal/ogr/ogrsf_frmts/shape to
define SHAPELIB_DLLEXPORT so that from now on defaults builds of GDAL
will export the shapelib api.

/* -------------------------------------------------------------------- */
/* SHPAPI_CALL */
/* */
/* The following two macros are present to allow forcing */
/* various calling conventions on the Shapelib API. */
/* */
/* To force __stdcall conventions (needed to call Shapelib */
/* from Visual Basic and/or Dephi I believe) the makefile could */
/* be modified to define: */
/* */
/* /DSHPAPI_CALL=__stdcall */
/* */
/* If it is desired to force export of the Shapelib API without */
/* using the shapelib.def file, use the following definition. */
/* */
/* /DSHAPELIB_DLLEXPORT */
/* */
/* To get both at once it will be necessary to hack this */
/* include file to define: */
/* */
/* #define SHPAPI_CALL __declspec(dllexport) __stdcall */
/* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */
/* */
/* The complexity of the situtation is partly caused by the */
/* peculiar requirement of Visual C++ that __stdcall appear */
/* after any "*"'s in the return value of a function while the */
/* __declspec(dllexport) must appear before them. */
/* -------------------------------------------------------------------- */

#ifdef SHAPELIB_DLLEXPORT
# define SHPAPI_CALL __declspec(dllexport)
# define SHPAPI_CALL1(x) __declspec(dllexport) x
#endif

#ifndef SHPAPI_CALL
# define SHPAPI_CALL
#endif

#ifndef SHPAPI_CALL1
# define SHPAPI_CALL1(x) x SHPAPI_CALL
#endif

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
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