根据此文档http://www.cplusplus.com/reference/clibrary/ctime/time/
for time(NULL)"如果函数无法检索日历时间,则返回-1值."
这是我应该在我的代码中检查的内容吗?如果时间(NULL)没有检索时间,肯定会出现一些错误.
ato*_*ice 17
您可能正在没有实时时钟的嵌入式设备上运行.
glibc源代码声称在Linux上时间系统调用不会失败:
time_t res = INTERNAL_SYSCALL (time, err, 1, NULL);
/* There cannot be any error. */
Run Code Online (Sandbox Code Playgroud)
如果你看一下内核源代码就是这种情况:
SYSCALL_DEFINE1(time, time_t __user *, tloc)
{
time_t i = get_seconds();
if (tloc) {
if (put_user(i,tloc))
return -EFAULT;
}
force_successful_syscall_return();
return i;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1611 次 |
| 最近记录: |