得到了编译错误,当使用clock_gettime在C99 [英] got compile error when use clock_gettime in c99

查看:796
本文介绍了得到了编译错误,当使用clock_gettime在C99的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在code段使用clock_gettime,并与标志编译-std = C99,我得到了一个错误是这样的:

when I use clock_gettime in my code snippet, and compile with flag -std=c99, I got a error like this:

warning: implicit declaration of function 'clock_gettime'
error: 'CLOCK_REALTIME' undeclared (first use in this function)

和我已经包含了文件'time.h中。
任何人都知道如何解决它。

and I have included the file 'time.h'. anyone knows how to fix it.

推荐答案

在你原来的code。与-std = C99,尝试添加

in your original code with -std=c99, try adding

#define _POSIX_C_SOURCE >= 199309L

有关clock_gettime手册页表示这是一个必要的功能测试宏要求。

the man page for clock_gettime indicates this is a necessary feature test macro requirement.

这篇关于得到了编译错误,当使用clock_gettime在C99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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