I don't think sleep is part of ANSI C Standard, so you should not expect it
to be portable at all -- at least not outside of POSIX. If you did something
portable across POSIX and Win32, do as Oleg says, Wrap it!
MSVC 6 does not define sleep at all, but only _sleep is defined in stdlib.h
(however, since it is deprecated it cannot be found in MSDN and only
retained for compatibility). MinGW follows (of course) MSVC and only defines
_sleep (so I don't think redefining _sleep is a good idea -- a source of
conflict and non-portability!). A tiny difference between MinGW and MSVC is
that sleep is allowed to use though not defined in MinGW! The import library
will resolve both "sleep" and "_sleep" to "_sleep" in MSVCRT.DLL.
To complicate the circumstance even worse, I found that Borland C++ 5.5
treat sleep (and _sleep) in the POSIX way! So my idea now is:
# if defined(_MSC_VER) || defined(__MSVCRT__)
# define sleep(t) _sleep((t) * 1000)
It is the most compatible way I know up to now. As far as I know, it will
pass MSVC 6, BCC 5.5, MinGW, Cygwin, and supposedly all POSIX C compilers.