简体   繁体   English

在OSX上编译的ctime和time警告

[英]ctime and time warnings compiling on OSX

I am getting some warnings when compiling a C program on OSX 10.6.5, which seem to be quite critical. 在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’

The corresponding lines are as follows: 相应的行如下:

Lines 13-15: 第13-15行:

RANDNUMGEN = gsl_rng_alloc(gsl_rng_taus);
long t1;
(void) time(&t1);

Lines 360-363: 360-363行:

if (LOG==NULL) { LOG=stdout;}

TVAL = time(NULL);
char* TIMESTRING = ctime(&TVAL);

I believe the program was originally written for Linux, so I wonder if there is a difference between time and ctime on the two platforms? 我相信该程序最初是为Linux编写的,所以我想知道两个平台上的timectime之间是否有区别?

Verify that the C files contains: 验证C文件包含:

#include <time.h>

somewhere around the top. 顶部附近的某个地方。

Also, 也,

long t1;
time(t1);

is pretty lousy code, the argument to time() has type time_t* , so that should read 是很糟糕的代码, time()的参数类型为time_t* ,因此应读取

time_t t1;
time(&t1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM