I am writing a program which includes both /usr/include/linux/time.h
and /usr/include/stdlib.h.
The problem is:
stdlib.h
includes /usr/include/time.h
, which defines 'struct timespec'
, and /usr/include/linux/time.h
also defines one. This introduces a compilation error of redefinition.
I've examined the definitions of 'struct timespec'
in these two header files:
in /usr/include/time.h:
struct timespec
{
__time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
in /usr/include/linux/time.h:
struct timespec {
__kernel_time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
It seems that these definitions are indeed equivalent, but I can't prove it.
My question is: is there a robust way to resolve this redefinition?
Links to discussions on this problem are also highly appreciated. Thanks.