[GRASS-dev] g.mapsets use of sleep()
Hamish
hamish_nospam at yahoo.com
Tue Dec 5 20:43:44 EST 2006
Glynn Clements wrote:
>
> 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.
so #include <unistd.h> is no good in windows?
isn't the system("ls") going to be a problem as well?
> 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.
AFAIR, Paul's error is exactly why Radim added G_sleep().
and finally, WRT g.mapsets, sleep isn't really needed*, so why not:
[*] not followed by a clear screen command.
- sleep(3);
- exit(1);
+ G_fatal_error("");
or
+ G_fatal_error("Available mapsets:\n%s", mapset_string);
Hamish
More information about the grass-dev
mailing list