在 OSX 上编译的 ctime 和 time 警告 [英] ctime and time warnings compiling on OSX

查看:58
本文介绍了在 OSX 上编译的 ctime 和 time 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OSX 10.6.5 上编译 C 程序时收到一些警告,这似乎很关键.

I am getting some warnings when compiling a C program on OSX 10.6.5, which seem to be quite critical.

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 行:

Lines 360-363:

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

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

我相信这个程序最初是为Linux编写的,所以我想知道两个平台上的timectime有区别吗?

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?

推荐答案

验证 C 文件是否包含:

Verify that the C files contains:

#include <time.h>

顶部的某个地方.

还有,

long t1;
time(t1);

是非常糟糕的代码,time() 的参数类型为 time_t*,所以应该读取

is pretty lousy code, the argument to time() has type time_t*, so that should read

time_t t1;
time(&t1);

这篇关于在 OSX 上编译的 ctime 和 time 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆