From: Brian D. <br...@de...> - 2007-05-18 19:45:35
|
Roger Wells wrote: > not so fast. > when I am using MinGW with gcc 3.3.1 code using sleep() compiles, links > and runs as expected > on the other hand using MinGW gcc 3.4.5, code using sleep() reports it > as an unresolved reference at link time. > replacing sleep with _sleep in the source files fixes this. > > versions: > gcc version 3.3.1 (mingw special 20030804-1) > GNU ld version 2.13.90 20030111 > and > gcc version 3.4.5 (mingw special) > GNU ld version 2.17.50 20060716 > > Also sleep is a common function but not completely standard (no mention > of it in ISO/IEC 9899 "C" spec). It is, however, included in the POSIX > standard. In any case it is dangerous since on Win32 the argument is > milliseconds and on POSIX implementations (e.g., RHEL 4.0) the units are > seconds. You can do that, but you're using an undocumented, obsolete, and deprecated interface that could disappear in future revisions of MSVCRT. This is not a good idea in terms of general programming practice. /* * NOTE: Officially the three following functions are obsolete. The Win32 API * functions SetErrorMode, Beep and Sleep are their replacements. */ _CRTIMP void __cdecl _beep (unsigned int, unsigned int) __MINGW_ATTRIB_DEPRECATED; /* Not to be confused with _set_error_mode (int). */ _CRTIMP void __cdecl _seterrormode (int) __MINGW_ATTRIB_DEPRECATED; _CRTIMP void __cdecl _sleep (unsigned long) __MINGW_ATTRIB_DEPRECATED; _CRTIMP void __cdecl _exit (int) __MINGW_ATTRIB_NORETURN; Brian |