11.23 gettimeofday
¶
Removed in POSIX.1-2024.
POSIX.1-2017 specification:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html
Gnulib module: gettimeofday
Portability problems fixed by Gnulib:
- This function is missing on some platforms:
MSVC 14.
- This function is declared with a nonstandard function prototype (only one
argument, or “...” after the first argument) on some platforms.
- On some platforms, the second argument has type
struct
timezone*
rather than void *
, making it an error to redeclare
the function with the POSIX signature:
glibc.
However, rather than penalize these systems with a replacement
function, gnulib defines GETTIMEOFDAY_TIMEZONE
to the
appropriate type for use in avoiding a compiler warning if assigning
gettimeofday
to a function pointer.
- This function has only a precision of 15.6 milliseconds on some platforms:
mingw.
Portability problems not fixed by Gnulib:
- Behavior is non-portable if the second argument to
gettimeofday
is not NULL
.
- This function is removed in POSIX.1-2024.
Use the Gnulib module
gettime
or timespec_get
instead.
(POSIX recommends to use the function clock_gettime
, but there is
no corresponding Gnulib module for it yet.)