Skip to content
Sign upLog in

Delay for c++

Profile icon

Does anyone know a compatible delay function for c++? I would like to use it to make the computer slow down, and make it easier for calculations. Thanks!

You are viewing a single comment. View All
Profile icon


For one, the compiler will tell you what's wrong if there are any undefined references or functions. It's hard to form a bad habit using a function when the program in question won't even compile on a different operating system.

Secondly, constantly checking what is portable for all libraries or functions is also a hindrance. Slowing down development time on something that will never release on other platforms is pointless. Portability is something that needs to be decided from the design stage. If there's no need for portability, anything done about it is just wasted time.

Thirdly, the unistd.h library IS standard for Unix operating systems. It has documentation for it just as C++ libraries do. Neither sleep() nor sleep_for() imply what unit of measurement is being used. The documentation will, hopefully, contain this information.

Fourthly, naming of things are much more impactful than whether or not they are standard.

sleep(one_second) versus sleep(1000)

Portability should only be a priority when something is intended to be portable. It isn't always better one way or the other.