Page 1 of 1

clock_gettime() not compiling

Posted: Fri Feb 07, 2020 3:56 pm
by comperem
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?

Re: clock_gettime() not compiling

Posted: Sat Apr 16, 2022 1:45 am
by ySh_zZpp
同样的情况 ,请问解决了么?