[geos-devel] Portability
Norman Vine
nhv at cape.com
Fri Aug 30 15:24:37 EDT 2002
Paul Ramsey writes:
> So, working through the compilation bit by bit, some problems seem to be:
>
> - occasionally stdio.h is not declared where it is needed (maybe VC++
> papers over this automatically)
> - the compiler cannot find declarations for __min() and __max(),
> although it *can* find declarations for min() and max(). What is the
> difference between them? In GeometryCollection.cpp line 55, __max() is
> used while an almost identical function just above it uses max().
My experience with several cross-platform libraries is that we will have
LOTS of problems with MSVC6 and GCC incompatabilities.
One way around this is to have a <compiler.h> file that hides the
platform specifc 'quirks' or have the MSVC folks use the STLPort
STL headers. The STLPort approach is probably the easiest
http://www.stlport.org
For common simple things like min() and max() most libraries
I help develop define their own versions
something like
// geos_inlines.h
#ifndef _GEOS_INLINES_H
#define _GEOS_INLINES_H
// return the sign of a value
template <class T>
inline int GEOS_SIGN(const T x) {
return x < T(0) ? -1 : 1;
}
// return the minimum of two values
template <class T>
inline T GEOS_MIN2(const T a, const T b) {
return a < b ? a : b;
}
// return the minimum of three values
template <class T>
inline T GEOS_MIN3( const T a, const T b, const T c) {
return (a < b ? SG_MIN2 (a, c) : SG_MIN2 (b, c));
}
ect ...
Cheers
Norman
More information about the geos-devel
mailing list