ChinaUnix.net
相关文章推荐:

localtime_r

操作环境:solaris 8 现象:程序启动,运行正常,但是运行一段时间之后,r="red">r="red">localtime_r 转换时间就比当前时间要晚16个小时,从而导致程序出现异常 如果是时区的环境变量变化了引起的,在程序启动的时候不就已经确定环境变量了?

by foolishfox - C/C++ - 2011-05-25 10:35:54 阅读(2671) 回复(3)

相关讨论

r="red">r="red">localtime_r和mktime是用来在时间分量和时间秒数之间进行转换的标准c函数。但是线程不安全。 有位大侠提供了两种方法: 1、自己实现mktime和r="red">r="red">localtime_r,但是这样时区的计算是麻烦的,当然也可以不使用时区信息,或者使用固定时区,比如北京时区,这样就简单多了。 2、用pthread的mutex来给mktime和r="red">r="red">localtime_r加锁,但是这样要使用pthread库,移植性不够好。 请问各位大牛有没有更好的方案来使用这两个方法? 另: 那位先生...

by aple_smx - C/C++ - 2010-08-07 09:36:29 阅读(24255) 回复(19)

-bash-2.05b$ g++ -v reading specs from /usr/local/lib/gcc/hppa2.0w-hp-hpux11.11/3.4.3/specs Configured with: ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure Thread model: single gcc version 3.4.3 一个cpp文件中包含这样的代码: [code] #include time_t tt; struct tm ut;...

by dajun - C/C++ - 2006-10-09 17:40:57 阅读(5382) 回复(13)

我用lcoaltime_r取时间,取出的时间有时比标准时间多了一个小时, 不知那位高手能告知原因,多谢。

by cnnjct - C/C++ - 2004-04-21 19:25:54 阅读(10483) 回复(10)

#include read.h> #include void test(char *arg) { pthread_detach(pthread_self()); struct tm now; time_t datetime; while (1) { time (&datetime); r="red">r="red">localtime_r(&datetime, &now); usleep(10); } } int main() { int rt; int tid[7]; pthread_create(&tid[0], NULL, test, NULL); pthread_create(&tid[1], NULL,...

by wzabcd1234 - C/C++ - 2010-06-25 16:40:29 阅读(4691) 回复(5)

我在 SUN880 Solaris8上开发了一个多线程程序,使用pthread线程,用 cc 编译器进行编译。 程序的线程结构是这样,主线程启动后创建了4个 pthread 线程,这四个 pthread 线程一直运行,直到进程结束才退出。因为需要在多个线程中同时获取系统时间,所以程序中使用了 localltime_r 函数。各个线程中对 localltime_r 的调用频度很高,每秒平均 200 多次,现在发现这样的问题,程序运行起来后,10几秒很快出现内存访问错误。用dbx查看...

by tu2y - C/C++ - 2008-09-25 11:05:10 阅读(4255) 回复(4)

我在 SUN880 Solaris8上开发了一个多线程程序,使用pthread线程,用 cc 编译器进行编译。 程序的线程结构是这样,主线程启动后创建了4个 pthread 线程,这四个 pthread 线程一直运行,直到进程结束才退出。因为需要在多个线程中同时获取系统时间,所以程序中使用了 localltime_r 函数。各个线程中对 localltime_r 的调用频度很高,每秒平均 200 多次,现在发现这样的问题,程序运行起来后,10几秒很快出现内存访问错误。用dbx查看...

by tu2y - Solaris - 2004-07-14 20:00:19 阅读(814) 回复(2)

我在 SUN880 Solaris8上开发了一个多线程程序,使用pthread线程,用 cc 编译器进行编译。\r\n 程序的线程结构是这样,主线程启动后创建了4个 pthread 线程,这四个 pthread 线程一直运行,直到进程结束才退出。因为需要在多个线程中同时获取系统时间,所以程序中使用了 localltime_r 函数。各个线程中对 localltime_r 的调用频度很高,每秒平均 200 多次,现在发现这样的问题,程序运行起来后,10几秒很快出现内存访问错误。用dbx...

by tu2y - Solaris - 2004-07-14 20:00:19 阅读(2702) 回复(2)

我发现该函数在c程序中可以正常使用,但在c++程序中无法编译,哪位大侠知道原因? 谢了先!

by 岁月如烟 - C/C++ - 2003-07-04 15:26:22 阅读(4221) 回复(13)

1、Definition and Usage 定义和用法 The r="red">localtime() function returns an array that contains the time components of a Unix timestamp. r="red">localtime()函数的作用是:以数组的形式返回本地时间。 2、Syntax 语法 r="red">localtime(timestamp,is_associative) Parameter参数 Description描述 timestamp Optional. Specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time. 可选参数。...

by ruoyisiyu - php文档中心 - 2007-09-11 17:03:19 阅读(1015) 回复(0)

使用stat取到文件属性,使用其中的时间,然后用r="red">localtime转换为年月日的形式,但这个时间和正确的时间相差一个月.

by avcodec - C/C++ - 2014-08-09 17:30:35 阅读(3616) 回复(9)