需要在代码中添加头文件。示例如下:
#include #include
int main() { struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { printf("Current time: %ld.%09ld seconds since Epoch\n", (long)ts.tv_sec, ts.tv_nsec); } else { printf("clock_gettime failed\n"); } return 0; }
上一篇:编译时出现错误:errorLNK2038:对于“_COROUTINE_ABI”,检测到不匹配:值“2”与Qt6Cored.lib(qlocale_win.cpp.obj)中的值“1”不匹配。
下一篇:编译时出现错误:libm.so.6: 添加符号时出错:DSO丢失,已经包含 -lm。