[Qgis-developer] Patch for compiling qgis-0.8pre2 with
geos-3.0.0rc3
Tom Elwertowski
telwertowski at comcast.net
Sat Dec 16 01:56:25 EST 2006
Mike Leahy wrote:
> Gary Sherman wrote:
>> Does this mean that it will also compile with GEOS 2.x?
>
> Sorry, it is 3.x only. With my very limited understanding of c++
> programming, I can only guess if it's even possible to allow compiling
> against both 2.x and 3.x.
I see several possibilities here:
One is to add the following to each file with removed namespace prefixes.
#if GEOS_VERSION_MAJOR < 3
using namespace geos;
#endif
This is ok for cpp files but not a good idea for h files because it can
result in name collisions in unexpected places if the h file is widely
included.
Another idea is to change our prefixes from "geos" to "GEOS" or
something similar if "GEOS" is already in use and then add the following
after figuring out what the new namespace is:
#if GEOS_VERSION_MAJOR < 3
#define GEOS geos
#else
#define GEOS geos3whatever
#endif
This technique avoids having headers propagate the "using" clause into
unexpected places.
Your changes to what geos headers to include may also need a bit of
adjustment to work with both 2 and 3.
I have not installed GEOS 3 because I thought that the API had changed
and code needed to be revised. Your patches seem to indicate that
existing code probably still works and just the namespace has changed.
I will install GEOS 3 and try this myself. Thanks for doing the research.
Tom
More information about the Qgis-developer
mailing list