clock_gettime() not compiling

comperem
Posts: 4
Joined: Sat Jan 25, 2020 8:08 pm

clock_gettime() not compiling

Postby comperem » Fri Feb 07, 2020 3:56 pm

Hello,
I cannot get the Arduino IDE to find and compile `clock_gettime()`.

My error is: `'clock_gettime' was not declared in this scope`

Here's the simple sketch:

Code: Select all

#include "time.h"

struct timespec tp;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  double tNow;
  long dt_sec, dt_nsec;
  
  clock_gettime(CLOCK_REALTIME, &tp);  
  tNow = tp.tv_sec+(tp.tv_nsec/1.0e9);
  Serial.print("tNow=,%20.10f, tNow_sec=,%16.10ld, tNow_nsec=,%16.10ld, dt_sec=%16li(s), dt_nsec=%16li(s)", tNow, tp.tv_sec,tp.tv_nsec, dt_sec, dt_nsec);
  
  delay(1000);
}
How can I get this to compile?

Who is online

Users browsing this forum: Baidu [Spider] and 19 guests