我在Linux机器上运行。如何检查我的系统是否支持使用 CLOCK_MONOTONIC? 我试图在程序中使用它并得到奇怪的结果。问题可以在这里看到: https://stackoverflow.com/questions/21774286/calculating-time-elapsed-in-c-using-monotonic-clock-results-dont-make-sense
我开始认为这是因为幕后发生了一些奇怪的事情?
最佳答案
[clock_gettime()
的手册页说得很清楚:
Return Value
clock_gettime(), clock_settime() and clock_getres() return 0 for success, or -1 for failure (in which case errno is set appropriately).
因此,您需要检查返回值,而另一个问题中链接到的代码无法执行此操作。
关于c - 我的系统支持单调时钟吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21774862/