当我在我的代码片段中使用 clock_gettime,并使用标志 -std=c99 进行编译时,我得到了这样的错误:
warning: implicit declaration of function 'clock_gettime'
error: 'CLOCK_REALTIME' undeclared (first use in this function)
并且我包含了文件“time.h”。 任何人都知道如何修复它。
最佳答案
在您使用 -std=c99 的原始代码中,尝试添加
#define _POSIX_C_SOURCE >= 199309L
clock_gettime 的手册页表明这是一项必要的功能测试宏要求。
关于c - 在 c99 中使用 clock_gettime 时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13069758/