当前位置:网站首页>localtime居然不可重入,踩坑了
localtime居然不可重入,踩坑了
2022-07-01 12:33:00 【涛歌依旧】
最近踩坑了,全都拜localtime所赐,因为localtime居然不可重入:
[email protected]:~$ man localtime
CTIME(3) Linux Programmer's Manual CTIME(3)
NAME
asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, localtime_r - transform date and time to broken-
down time or ASCII
SYNOPSIS
#include <time.h>
char *asctime(const struct tm *tm);
char *asctime_r(const struct tm *tm, char *buf);
char *ctime(const time_t *timep);
char *ctime_r(const time_t *timep, char *buf);
struct tm *gmtime(const time_t *timep);
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *timep, struct tm *result);
time_t mktime(struct tm *tm);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
asctime_r(), ctime_r(), gmtime_r(), localtime_r():
_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE
DESCRIPTION
The ctime(), gmtime() and localtime() functions all take an argument of data type time_t, which represents calendar time.
When interpreted as an absolute time value, it represents the number of seconds elapsed since the Epoch, 1970-01-01
00:00:00 +0000 (UTC).
The asctime() and mktime() functions both take an argument representing broken-down time, which is a representation sepa[m
rated into year, month, day, and so on.
Broken-down time is stored in the structure tm, which is defined in <time.h> as follows:
struct tm {
int tm_sec; /* Seconds (0-60) */
int tm_min; /* Minutes (0-59) */
int tm_hour; /* Hours (0-23) */
int tm_mday; /* Day of the month (1-31) */
int tm_mon; /* Month (0-11) */
int tm_year; /* Year - 1900 */
int tm_wday; /* Day of the week (0-6, Sunday = 0) */
int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */
int tm_isdst; /* Daylight saving time */
};真的需要小心一点。
边栏推荐
- Common chart usage of Bi tools
- 顺序表有关操作
- 队列操作---
- ASTM D 3801 vertical burning test of solid plastics
- fatal error: execution: 没有那个文件或目录
- Message queue monitoring refund task batch process
- usb peripheral 驱动 - cable connect/disconnect
- Ansi/ul 94 VTM vertical burning test for thin materials
- Technology sharing | MySQL: how about copying half a transaction from the database?
- [JS] interview questions
猜你喜欢
![[20220605] Literature Translation -- visualization in virtual reality: a systematic review](/img/11/6c42957186bf530e8f9d4025a40197.png)
[20220605] Literature Translation -- visualization in virtual reality: a systematic review

I wish you all a happy reunion

【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN

2022-06-28-06-29

LeetCode力扣(剑指offer 31-35)31. 栈的压入弹出序列32I.II.III.从上到下打印二叉树33. 二叉搜索树的后序遍历序列34. 二叉树中和为某一值的路径35. 复杂链表的复制

双链表有关操作

Share several tools for designing exquisite circuit diagrams

Machine learning - Data Science Library - day two

Use of easyexcel
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 5](/img/f5/9c68b3dc30362d3776c262fdc13fd0.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 5
随机推荐
Zero copy technology of MySQL
【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
腾讯黎巍:深耕“监管科技”,护航数字经济行稳致远
Ansi/ul 94 VTM vertical burning test for thin materials
leetcode 406. Queue reconstruction by height
One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
数字信号处理——线性相位型(Ⅱ、Ⅳ型)FIR滤波器设计(2)
Tencent Li Wei: deeply cultivate "regulatory technology" to escort the steady and long-term development of the digital economy
[brain opening] west tide and going to the world series
双链表有关操作
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
kubernetes之ingress探索实践
Efforts at the turn of the decade
STM32 project practice (1) introduction and use of photosensitive resistor
What are the PHP FPM configuration parameters
[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1
GPS 数据中的精度因子(DOP)与协方差之间的关系 (参考链接)
[Maui] add click events for label, image and other controls
[106] 360 check font - check whether the copyright of local Fonts is commercially available
LeetCode 454. Add four numbers II