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

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

问题描述

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

I searched my Linux box and saw this typedef:

typedef __time_t time_t;

但是我找不到__time_t定义.

推荐答案

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 integer(通常为32或64位宽) 代表秒数 自Unix时代开始以来: 1970年1月1日午夜UTC(非 计算leap秒).一些系统 正确处理负时间值, 而其他人则没有.系统使用 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.

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

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