[postgis-devel] Min, Max and Abs functions

strk at refractions.net strk at refractions.net
Thu Nov 4 02:28:10 PST 2004


On Thu, Nov 04, 2004 at 09:53:14AM -0000, Mark Cave-Ayland wrote:
> Hi everyone,
(cuts)
> Is there any reason why we shouldn't use these in PostGIS? From memory,
> there are several definitions of min(), max() and abs() particularly in the
> 0.9 branch which must be defined if using certain compilers like MingW and
> Cygwin. It strikes me that the code could be tidied up and made consistent
> across all platforms by making use of the PostgreSQL operators instead.
> 
> For reference, the current CVS contains the following in liblwgeom.h:
> 
> //#if ! defined(__MINGW32__)
> #define max(a,b)		((a) >	(b) ? (a) : (b))
> #define min(a,b)		((a) <= (b) ? (a) : (b))
> //#endif
> #define abs(a)			((a) <	(0) ? (-a) : (a))
> 
> While the definitions are slightly different in the cases where equal
> numbers are involved, since the macros are #defined it should just be the
> result which is altered since none of the parameters are passed by
> reference.
> 
> 
> Thoughts?
> 
> Mark.

Mark, for the 0.9 branch I think we should either use
postgresql defines or owr own defines. 
Can't remember why the __MINGW32__ switch was there, though...

For the head branch the fact is that liblwgeom.h has been prepared
to be completely independent from postgresql, in this case we
should have our own version.

Maybe the we should rename them to pgsql_{min,max,abs} in order
to avoid name clashes and keep using private versions.
If name clashes are not a problem

--strk;



More information about the postgis-devel mailing list