开发者

invalid conversion from time_t to const time_t*

time_t raw_time = time(NULL);
tm* current_time = localtime(&raw_time);

I got the answer myself... I totally开发者_C百科 messed up the warnings. Thanks anyway.


The localtime() function dates back to when (int) was 16 bits and passing (long) on the stack was not widely supported; as such, it was specified to pass (long *), which at the time was 16 bits. It's been left as is because changing it would break enormous amounts of code. You'll find that most of the time-related functions do this, since they were the only functions at the time that used (long). (lseek() came later. Care to guess what non-(long)-using function it replaced?)


localtime requires an argument of "time_t*" which is a pointer. So you have to put the & there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜