[GRASS-dev] g.mapsets use of sleep()

Markus Neteler neteler at itc.it
Fri May 18 09:54:31 EDT 2007


Moritz Lennert wrote on 05/18/2007 01:58 PM:
> On 16/05/07 22:58, Markus Neteler wrote:
>> [ MinGW compile errors for sleep() ]
>>
>>
>> Glynn Clements wrote:
>>> ...
>>> ... use G_sleep() instead:
>>>
>>> >From lib/gis/sleep.c:
>>>
>>>     unsigned int G_sleep (unsigned int seconds)
>>>     {
>>>     #ifdef __MINGW32__
>>>         /* TODO: no sleep for now */
>>>         return 0;        #else /* __MINGW32__ */
>>>         return sleep(seconds);
>>>     #endif /* __MINGW32__ */
>>>     }
>>>
>>> On MinGW, it doesn't actually sleep, but at least you don't get a link
>>> error.
>>>
>>
>> I have added there code for MinGW to use Sleep() and updated
>> all remaining sleep() to G_sleep().
>
> The implementation you used does not work:
>
> #ifdef __MINGW32__
>    return Sleep((seconds)*1000);
> #else
>
> The problem is that Sleep is void and thus does not give a value you
> can return (http://msdn2.microsoft.com/en-us/library/ms686298.aspx).
>
> We need something like this:
>
> #ifdef __MINGW32__
>    Sleep((seconds)*1000);
>    return 0;
> #else
>
I have fixed it like this for now.

Markus

> Just not sure: is 0 the correct value to return ? IIUC this is the
> value returned by the unistd.h version of sleep.
>
> Moritz


------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------




More information about the grass-dev mailing list