[geos-devel] Re: [postgis-users] GEOS / Predicates Update
Norman Vine
nhv at cape.com
Thu May 22 16:46:29 EDT 2003
David Blasby writes:
>
> > But... I can't help but wonder if the problem wouldn't automagically
> > disappear if we compiled the PostGIS code as C++ and made the
> > GEOS part of PostGIS a real C++ module that knew all about
> > handling exceptions
>
> I have thought about this, but havent experimented with it. I also
> experimented with statically linking the c++ library into postgis, but
> was unable to get it work (anyone know how to do it?).
You need to link with c++ not gcc
> It would be a good experiment to write a simple C++ plugin for
> postgresql and see if it has any problems. If this works, there
> shouldnt be any difficult problems converting PostGIS to C++ - but it
> could be time consuming.
Shouldn't be too much work as most of the existing code can be
#ifdef __cplusplus
extern "C" {
#endif
....
}
One thing I noticed whrn trying to compile the existing code with
C++ is that most of the allocs inside of PostGIS will need to be cast
appropriately
i.e instead of
char *result = palloc(size);
char *result = (char *)palloc(size);
This should probably be being done anyway !
Another gottcha is in PostgesSQL it self and *requires* a change
that should probably be brought to the pgsql developers attention
postgresql-7.3.2-1\src\include\nodes\memnodes.h
typedef struct MemoryContextMethods
{
void *(*alloc) (MemoryContext context, Size size);
/* call this free_p in case someone #define's free() */
void (*free_p) (MemoryContext context, void *pointer);
void *(*realloc) (MemoryContext context, void *pointer, Size size);
void (*init) (MemoryContext context);
void (*reset) (MemoryContext context);
void (*delete) (MemoryContext context);
^^^^^^^^^^
delete is a reserved word in C++ !!!
Cheers
Norman
More information about the geos-devel
mailing list