gmtime()/localtime() are not thread-safe

来源:互联网 发布:易语言摄像头监控源码 编辑:程序博客网 时间:2024/05/17 02:44

man 3 localtime

NOTES
       The four functions acstime(), ctime(), gmtime() and localtime() return a pointer to static data and hence are not thread-safe.   Thread-safe  versions acstime_r(), ctime_r(), gmtime_r() and localtime_r() are specified by
       SUSv2, and available since libc 5.2.5.

       The glibc version of struct tm has additional fields

              long tm_gmtoff;           /* Seconds east of UTC */
              const char *tm_tm_zone;   /* Timezone abbreviation */