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
error: 'TIMEVAL_TO_TIMESPEC' was not declared in this scope
TIMEVAL_TO_TIMESPEC (&tv, tp);
The below is the link that explains all date time concepts/standards from GNU C library, where most of the platforms stick to.
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.