也许,但我没看过comp.lang.c,不想花时间在那里筛选任何不相关的箔条,并且由于C89标准被纳入(通过引用)到C ++标准中,它似乎是相关的和在这里的主题。 pre-epoch(负数)。 Perhaps, but I don''t read comp.lang.c, don''t want to spend the time sifting through any unrelated chaff there, and since the C89 standard is incorporated (by reference) into the C++ Standard, it would seem to be relevant and on-topic here. I''m well aware that gmtime() takes a time_t*. I was wondering what gmtime is supposed to do if the *value pointed to by its parameter* is pre-epoch (negative). 你在这里再去!没有时代。除了 单个负值(-1)之外的负值仍然有效。标准中没有任何内容表示''time_t''也是算术(或积分)类型。可能在C ++中,''time_t''类型是用户定义的类型,只需 就可以转换为''int'',并且提供(-1)创建一个 类型''time_t''的对象,它以某种方式无效。因为你不应该在便携式程序中查看''time_t''的内容,并且只能使用 来回传递时间函数,任何实现的 类型都是可能的。 我认为这是隐含的理解。 标准方面没有任何暗示。我认为这是隐含的理解 。 我已经忘记了-1是无效的time_t。值。 所以它是特定的实现(什么是负时间)。那就是我在寻找的东西。由于我正在寻找可移植性,我会检查是否有预先调用的值,或者从gmtime返回0。Here you go again!.. There is no "epoch". Negative values, except thesingle negative value of (-1) can still be valid. Nothing in the Standardsays that ''time_t'' is an arithmetic (or integral) type, either. It ispossible that in C++ the type ''time_t'' is a user-defined type that simplyhas a conversion from, say, ''int'', and supplying (-1) creates an object oftype ''time_t'' that is somehow "invalid". Since you''re not supposed to belooking at the contents of ''time_t'' in a portable program, and only use itto pass back and forth between time functions, any implementation of thattype is possible. I had figured that was implicitly understood.There is nothing implicit when it comes to Standards. I thought that wasimplicitly understood. I had forgotten that -1 is the "invalid time_t" value. So it''s implementation specific (what "negative time" does). That''s what I was looking for. Since I''m looking for portability, I''ll check for negative values pre-call, or 0 returns from gmtime. 你可以' 便携式检查负值。未指明 _any_''time_t'的负值是不好的。它指定只有 (time_t)( - 1)是无效,这意味着没有可用的日历时间。 有两个函数在返回time_t 值的C标准库:''time''和''mktime''。我们知道他们_mey_返回一些东西 喜欢(time_t)( - 7777)它应该被认为是_valid_值(在那个 特定的实现中)。 VYou can''t portably "check for negative values". It is unspecified that_any_ negative value of ''time_t'' is bad. It specifies that only(time_t)(-1) is "invalid", meaning that no calendar time is available.There are two functions in the C Standard Library that return a time_tvalue: ''time'' and ''mktime''. For all we know they _may_ return somethinglike (time_t)(-7777) and it should be considered a _valid_ value (in thatparticular implementation).V 这篇关于gmtime()的正确行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!