I want to compile the following code on macos:
struct timeval tv;
int retval = gettimeofday (&tv, NULL);
if (retval == 0)
TIMEVAL_TO_TIMESPEC (&tv, tp); //here I am getting the error
return retval;
But I am getting the error
error: 'TIMEVAL_TO_TIMESPEC' was not declared in this scope
TIMEVAL_TO_TIMESPEC (&tv, tp);
I am compiling with the cross compiler of android. I tried to include the time.h header explicitly, and it still doesn't find TIMEVAL_TO_TIMESPEC. How can I dompile this code correctly?
The below is the link that explains all date time concepts/standards from GNU C library, where most of the platforms stick to.
https://www.gnu.org/software/libc/manual/html_node/Date-and-Time.html#Date-and-Time
If you are targeting a cross platform development better stick to the above standards.
Like "nathan" specified in comments, the macro used is specific to some UNIX like systems.
I quickly verified the GNU C library for date and time (above link). I did not see the "TIMEVAL_TO_TIMESPEC" macro any where.
May be operating systems that descends from "Berkeley Software Distribution" may have "TIMEVAL_TO_TIMESPEC", but may not be part of GNU standard C library, as far as I know.
Correct me If I am wrong.