我在linux框中搜索并看到它是typedef
typedef __time_t time_t;
Run Code Online (Sandbox Code Playgroud)
但找不到__time_t定义.
除了精度的差异,struct timeval和之间有什么区别struct timespec?如果我需要的精度低于μs(比如毫秒),为什么我要使用一个而不是另一个?
在我的编译器(ARM的gcc)上:
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
Run Code Online (Sandbox Code Playgroud)
随着双方__syscall_slong_t并__suseconds_t定义为"长字".