[postgis-devel] Determining Endianess

strk strk at keybit.net
Mon Feb 9 10:55:12 PST 2004


I've included your code in pgsql2shp.
It would be needed for postgis_inout.c
and postgis_gist*.c where its computation
time will be more noticeable.

I've asked to the pgsql-hackers about using their computed
BYTE_ORDER.  Yet, I'd see better having Dave's code as an m4 macro
and postgis switch to autoconf.

dblasby wrote:
> Here's a piece of code that directly tests the endian of the machine.
> Basically, it looks at how the number 1 is stored.  In the 4 byte int, 
> if its NDR, it will be in the 1st byte.  If its XDR, it'll be in the 
> last byte.
> 
> 	int test = 1;
> 
> 	if ( (((char *)(&test))[0]) == 1)
> 	{
> 		//NDR
> 	}
> 	else
> 	{
> 		//XDR
> 	}
> 
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list