[GRASS-dev] r.random still broken on Mac

William Kyngesburye woklist at kyngchaos.com
Thu Sep 28 13:58:39 EDT 2006


__APPLE__ is still around.  I don't think it'll go away.  Handy  
little trick I found somewhere:

touch foo.h; cpp -dM foo.h

What was the problem before?  is *rand48 broken on OS X?  I see in my  
config.h that HAVE_DRAND48 is defined.  Or that having drand48  
doesn't mean there is lrand48?

If it's broken, I noticed that r.mapcalc's xrand.c also uses lrand48,  
but it still tests for HAVE_DRAND48 instead of __APPLE__.  And it  
uses a different define for when HAVE_DRAND48 is not defined.

On Sep 28, 2006, at 12:20 PM, Glynn Clements wrote:

>
> Michael Barton wrote:
>
>> r.random is broken on the Mac at least. It jams all the points  
>> into the top
>> edge of the screen instead of actually randomly distributing them.  
>> I thought
>> this was fixed months back. If it was, it¹s broken again and needs  
>> to be
>> fixed for GRASS 6.2.
>>
>> This happens with both vector and raster points, and both from the  
>> GUI and
>> command line.
>
> Probably because the "fix" tries to identify specific platforms rather
> than testing the HAVE_DRAND48 macro:
>
> 	#if defined(__CYGWIN__) || defined(__APPLE__) || defined(__MINGW32__)
> 	#define lrand48() ((long)((double) rand() * (1<<31) / RAND_MAX))
> 	#define srand48(sv) (srand((unsigned)(sv)))
> 	#else
> 	extern long lrand48();
> 	extern void srand48();
> 	#endif
>
> I'm guessing that the OSX compiler doesn't define __APPLE__ any more.
>
> In general: platform tests are a bad idea. Test the features which you
> actually want to use. If you need a configure test, and don't know how
> to write it yourself, make a request to the list.
>
> -- 
> Glynn Clements <glynn at gclements.plus.com>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/

"Oh, look, I seem to have fallen down a deep, dark hole.  Now what  
does that remind me of?  Ah, yes - life."

- Marvin






More information about the grass-dev mailing list