【问题标题】:Why tm_gmtoff field of struct tm is not documented in man page?为什么 struct tm 的 tm_gmtoff 字段未在手册页中记录?
【发布时间】:2021-05-06 07:12:02
【问题描述】:

我需要在 Linux 上使用 GCC 来获取 UTC 和本地时间之间的差异。 似乎首选的方法是检查struct tmlocaltime 函数返回的tm_gmtoff 字段。

https://stackoverflow.com/a/47218792

但是,tm_gmtoff 没有记录在 localtime 的手册页中,但是 只有tm_zone 是。

https://man7.org/linux/man-pages/man3/localtime.3.html

头文件中似乎存在tm_gmtofftm_zone

  19 # ifdef __USE_MISC
  20   long int tm_gmtoff;           /* Seconds east of UTC.  */
  21   const char *tm_zone;          /* Timezone abbreviation.  */
  22 # else
  23   long int __tm_gmtoff;         /* Seconds east of UTC.  */
  24   const char *__tm_zone;        /* Timezone abbreviation.  */
  25 # endif

https://sourceware.org/git/?p=glibc.git;a=blob;f=time/bits/types/struct_tm.h;h=b13b631228d0ec36691b25db2e1f9b1d66b54bb0;hb=HEAD

我不确定为什么手册页中省略了tm_gmtoff。会不会是以下提交中引入的手册页错误?

https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man3/ctime.3?id=ba39b288ab07149417867533821300256f310615&h=master

【问题讨论】:

  • Here 它说:The tm_gmtoff field is derived from BSD and is a GNU library extension; it is not visible in a strict ISO C environment.
  • @ssbssa 但它也对tm_zone说同样的话:Like tm_gmtoff, this field is a BSD and GNU extension, and is not visible in a strict ISO C environment.

标签: linux gcc


【解决方案1】:

我将此情况报告给了维护人员。它已通过以下提交修复。

https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=20f1ee93171895341877b8c5679a33823c4ca582

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-02
    • 2016-01-25
    • 2021-11-02
    • 2012-08-27
    • 2020-07-23
    • 1970-01-01
    • 2016-05-25
    • 2012-05-06
    相关资源
    最近更新 更多