相关疑难解决方法(0)

什么是time_t typedef到底是什么?

我在linux框中搜索并看到它是typedef

typedef __time_t time_t;
Run Code Online (Sandbox Code Playgroud)

但找不到__time_t定义.

c linux types

188
推荐指数
6
解决办法
27万
查看次数

c timeval vs timespec

除了精度的差异,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定义为"长字".

c linux time

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×2

linux ×2

time ×1

types ×1