c ++,usleep()已过时,Windows / MingW的解决方法? [英] c++, usleep() is obsolete, workarounds for Windows/MingW?

查看:4060
本文介绍了c ++,usleep()已过时,Windows / MingW的解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发现了另一个问题,Windows / MingW不提供nanosleep()和setitimer()替代过时的usleep()。
但我的目标是修复cppcheck给我的所有警告,包括usleep()风格警告。

I already found out with another question that Windows/MingW doesn't provide the nanosleep() and setitimer() alternatives to the obsolete usleep(). But my goal is to fix all warnings that cppcheck gives me, including the usleep() style warnings.

所以,有一个解决方法,以避免usleep ()在Windows上没有使用cygwin或安装新的依赖项/库的负载?感谢。

So, is there a workaround to somehow avoid usleep() on Windows without using cygwin or installing loads of new dependencies/libraries? Thanks.

推荐答案

usleep()适用于微秒。在用于获取微秒级属性的窗口中,您应该使用 QueryPerformanceCounter( ) winapi函数。 在这里,您可以找到使用它的方式。

usleep() works with microseconds. In windows for getting microsecond precesion you should use QueryPerformanceCounter() winapi function. Here you can find how get that precesion using it.

这篇关于c ++,usleep()已过时,Windows / MingW的解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆