【发布时间】:2020-12-25 15:00:52
【问题描述】:
好吧,我放弃了。我一辈子都看不懂C!
-
下面time_t的结构是什么?
/usr/include/bits/types/time_t.h
#ifndef __time_t_defined #define __time_t_defined 1 #include <bits/types.h> /* Returned by `time'. */ typedef __time_t time_t; #endif
这里使用“time_t”:
/usr/include/bits/types/time_t.h
/* Return the current time and put it in *TIMER if TIMER is not NULL. */
extern time_t time (time_t *__timer) __THROW;
"__THROW" 抛出异常。
-
第一个“time_t”是返回值吗?什么是 它的“结构”?是我神秘的time_t.h吗 想不通?
-
什么是“时间”?这是函数的名称吗? 是第一个“time_t”定义的结构 “时间”的返回值?
-
第二个“time_t”是什么?为什么是两个?
-
我认为“*___timer”是一个指针,但是指向什么 结构?
-
tm.h 在上面的任何地方都使用过吗?
/usr/include/bits/types/struct_tm.h struct tm { int tm_sec; /* Seconds. [0-60] (1 leap second) */ int tm_min; /* Minutes. [0-59] */ int tm_hour; /* Hours. [0-23] */ int tm_mday; /* Day. [1-31] */ int tm_mon; /* Month. [0-11] */ int tm_year; /* Year - 1900. */ int tm_wday; /* Day of week. [0-6] */ int tm_yday; /* Days in year.[0-365] */ int tm_isdst; /* DST. [-1/0/1]*/ # ifdef __USE_MISC long int tm_gmtoff; /* Seconds east of UTC. */ const char *tm_zone; /* Timezone abbreviation. */ # else long int __tm_gmtoff; /* Seconds east of UTC. */ const char *__tm_zone; /* Timezone abbreviation. */ # endif };#endif
你的困惑,
【问题讨论】:
-
您需要非常精确地使用标题名称和标识符。
time_t和__time_t是不同的标识符。你提到tm.h,然后引用了一个完全不同的头文件。 -
嗨@Florian,
typedef __time_t time_t;表示time_t 属于__time_t 类型。我直接引用/usr/include/bits/types/time_t.h。你的不一样吗?