[英]ctime and time warnings compiling on OSX
在OSX 10.6.5上编译C程序时,我收到一些警告,这似乎很关键。
extras.c:15: warning: implicit declaration of function ‘time’
extras.c: In function ‘outlog’:
extras.c:363: warning: implicit declaration of function ‘ctime’
相应的行如下:
第13-15行:
RANDNUMGEN = gsl_rng_alloc(gsl_rng_taus);
long t1;
(void) time(&t1);
360-363行:
if (LOG==NULL) { LOG=stdout;}
TVAL = time(NULL);
char* TIMESTRING = ctime(&TVAL);
我相信该程序最初是为Linux编写的,所以我想知道两个平台上的time
和ctime
之间是否有区别?
验证C文件包含:
#include <time.h>
顶部附近的某个地方。
也,
long t1;
time(t1);
是很糟糕的代码, time()
的参数类型为time_t*
,因此应读取
time_t t1;
time(&t1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.