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

Glynn Clements glynn at gclements.plus.com
Tue Dec 5 19:16:47 EST 2006


Paul Kelly wrote:

> Since $(VASKLIB) was removed from the g.mapsets Makefile I get the 
> following error on Windows:
> gcc -L/c/grass/grass6/dist.i686-pc-mingw32/lib -Wl,--export-dynamic,--enable-run
> time-pseudo-reloc  -L/c/grass/lib         -DPACKAGE=\""grassmods"\" -o /c/grass/
> grass6/dist.i686-pc-mingw32/bin/g.mapsets.exe OBJ.i686-pc-mingw32/main_cmd.o OBJ
> .i686-pc-mingw32/dsply_path.o OBJ.i686-pc-mingw32/dsply_maps.o OBJ.i686-pc-mingw
> 32/get_maps.o /c/grass/grass6/lib/gis/OBJ.i686-pc-mingw32/fmode.o -lgrass_gis -l
> grass_datetime -lxdr -liberty -lws2_32    -lz      -lxdr -liberty -lws2_32    -l
> z
> OBJ.i686-pc-mingw32/main_cmd.o(.text+0x427): In function `main':
> c:/grass/grass6/general/g.mapsets/main_cmd.c:128: undefined reference to `sleep'
> 
> collect2: ld returned 1 exit status
> make: *** [/c/grass/grass6/dist.i686-pc-mingw32/bin/g.mapsets.exe] Error 1
> 
> Not at all sure what's the most elegant way of fixing it???

-		sprintf (command, "ls -C %s/%s 1>&2", G_gisdbase(), G_location());
+		sprintf (command, "ls -C %s/%s 1>&2 ; sleep 3", G_gisdbase(), G_location());
		system (command);
-		sleep (3);

?

OK, so it's not exactly "elegant", but assuming the existence of a
"sleep" command doesn't seem to be any more of a Unix-ism than
assuming the existence of an "ls" command.

Alternatively, 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.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list