0

Are there any fundamental differences between windows.h sleep function and same in unistd.h?

Except that unistd.h is from POSIX and windows.h is Windows native and that Sleep() takes milliseconds. Interested in the difference between their internal implementations.

Andrey
  • 101
  • 2
  • _"Are there any fundamental differences"_ Yes, `Sleep()` takes millisecond values, while `sleep()` takes seconds. – πάντα ῥεῖ Oct 24 '20 at 11:38
  • @πάνταῥεῖ, thank you. Are there any preferences to use one of them on Windows or they are completely the same? – Andrey Oct 24 '20 at 11:43
  • 1
    The preference is to use [`std::thread::sleep_for()`](https://en.cppreference.com/w/cpp/thread/sleep_for). – πάντα ῥεῖ Oct 24 '20 at 11:51
  • 1
    You need a CRT implementation that exposes posix functions on Windows. Like mingw64, a popular choice. Which does what they [all do](https://github.com/mirror/mingw-w64/blob/ecb4ff5498dfedd6abcbadb889b84fab19ee57b2/mingw-w64-crt/misc/sleep.c#L12), no difference. – Hans Passant Oct 24 '20 at 12:27
  • @HansPassant, thank you too! – Andrey Nov 03 '20 at 13:01

0 Answers0