time_t 最终的 typedef 是什么? [英] What is time_t ultimately a typedef to?

查看:25
本文介绍了time_t 最终的 typedef 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了我的 Linux 机器并看到了这个 typedef:

I searched my Linux box and saw this typedef:

typedef __time_t time_t;

但我找不到 __time_t 定义.

推荐答案

time_t 维基百科文章 文章对此有所说明.底线是 time_t 的类型在 C 规范中是没有保证的.

The time_t Wikipedia article article sheds some light on this. The bottom line is that the type of time_t is not guaranteed in the C specification.

time_t 数据类型是为存储而定义的 ISO C 库系统时间值.这些值是从标准 time() 返回库函数.这种类型是标准中定义的 typedef标题.ISO C 定义time_t 作为算术类型,但确实不指定任何特定类型,范围、分辨率或编码.也未指定的含义是应用于时间的算术运算价值观.

The time_t datatype is a data type in the ISO C library defined for storing system time values. Such values are returned from the standard time() library function. This type is a typedef defined in the standard header. ISO C defines time_t as an arithmetic type, but does not specify any particular type, range, resolution, or encoding for it. Also unspecified are the meanings of arithmetic operations applied to time values.

Unix 和 POSIX 兼容系统将 time_t 类型实现为 signed整数(通常为 32 或 64 位宽)代表秒数自 Unix 时代开始:UTC 时间 1970 年 1 月 1 日午夜(不是计算闰秒).一些系统正确处理负时间值,而其他人则没有.系统使用32 位 time_t 类型易受2038 年问题.

Unix and POSIX-compliant systems implement the time_t type as a signed integer (typically 32 or 64 bits wide) which represents the number of seconds since the start of the Unix epoch: midnight UTC of January 1, 1970 (not counting leap seconds). Some systems correctly handle negative time values, while others do not. Systems using a 32-bit time_t type are susceptible to the Year 2038 problem.

这篇关于time_t 最终的 typedef 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆