使用结构itimerspec时发生编译错误

使用结构itimerspec时发生编译错误,c,C,我正在尝试使用timerfd_create()和timer_settime()在C中编写一个计时器。 我用的是单调的时钟。但尽管我包括了这些头文件 #include <sys/timerfd.h> #include <sys/time.h> #include <sys/types.h> struct itimerspec timerValue; //This is how i defined the structure //some code g_fdRet

我正在尝试使用timerfd_create()和timer_settime()在C中编写一个计时器。 我用的是单调的时钟。但尽管我包括了这些头文件

#include <sys/timerfd.h>
#include <sys/time.h>
#include <sys/types.h>

struct itimerspec timerValue; //This is how i defined the structure
//some code
g_fdRetryTimer = timerfd_create(CLOCK_MONOTONIC, 0);

请帮忙!谢谢。

gcc<5.1.0默认标准是
-std=gnu90
。版本5.1.0,将默认值从
-std=gnu90
更改为
-std=gnu11

您应该使用
-std=gnu99
编译代码,以使标识符
时钟单调
可用


可能会提供更多详细信息。

请用标志显示编译命令。我使用了gcc-ctimer.c-o-ctimer。
error: storage size of ‘timerValue’ isn’t known
error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)