1

I am trying to write a timer in C using timerfd_create() and timer_settime(). I am using CLOCK_MONOTONIC. But though i include these header files,

#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);

I am consistently getting the following compilation errors.

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.)

Please help! Thanks.

aniztar
  • 2,443
  • 4
  • 18
  • 24

1 Answers1

0

gcc < 5.1.0 default standard is -std=gnu90. Version 5.1.0, changed the default from -std=gnu90 to -std=gnu11.

You should compile your code with -std=gnu99 to have the identifier CLOCK_MONOTONIC available.

This answer might provide more details.

Community
  • 1
  • 1
Martin
  • 3,960
  • 7
  • 43
  • 43