c++unixg++time.h

C/C++ - getrawmonotonic was not declared in this scope


I'm trying to use getrawmonotonic function in my C++ application (this question should be the same for C).

I tried both of the following includes to no avail:

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

Any idea how to get this function included?

I'm using GCC. Is there a special compiler option needed?

I am compiling on Ubuntu 20.


Solution

  • This is a function inside the Linux kernel. Programs can't call it, just like they can't call functions inside other programs.

    You might be looking for the clock_gettime function with the argument CLOCK_MONOTONIC_RAW.