Sleep();, but not for Windows?

I'm releasing a product soon, and I'd like for it to be availabe on Mac computers as well as Windows. However I don't know any code that does the same function as Sleep() that isn't Windows specific? Would you help me out?
sleep/usleep/nanosleep. See http://www.manpagez.com/man/3/Sleep/
Will all of those work on Mac computers
They should. Macs are UNIX-compliant, after all.

EDIT: They won't necessarily work on Windows though. At least, not without some sort of workaround. I'd suggest using #ifs to check which platform you're compiling for, like:

1
2
3
4
5
6
7
8
#if defined(_WIN32)
//Windows code here.
#elif defined(__APPLE__) & defined(__MACH__)
//Mac code here.
#elif defined (__linux__)
//Linux code here, should you choose to use it. If not, delete the last #elif.
//sleep/usleep/nanosleep should also work on this platform.
#endif 


-Albatross
Last edited on
Alright. What I'll do is I'll have the Windows version that's already made, then a mac / linux version with one of the functions supplied here, problably nanosleep. Thanks a ton guys.
closed account (S6k9GNh0)
God forbid you use some cross-platform library...
In order to use the sleep function I've gotta have the unistd.h header file. Does anyone have a download link for it?
Topic archived. No new replies allowed.