[英]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.