gpt4 book ai didi

调用 stat 失败并出现 "Value too large for defined data type"错误

转载 作者:太空狗 更新时间:2023-10-29 17:07:18 29 4
gpt4 key购买 nike

给定 tmp.c:

#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>

int main(int argc, const char *argv[])
{
struct stat st;
if (stat(argv[1], &st) != 0)
{
perror("Error calling stat");
}

return 0;
}

当我在大文件 (~2.5 Gb) 上运行程序时,我得到 Error calling stat: Value too large for defined data type

最佳答案

需要 #define _FILE_OFFSET_BITS 64 : 要么在你之前添加它 #include <sys/stat.h>或以特定于平台的方式定义它,例如,对于 gcc,请参见 -D 选项;对于 Visual Studio,转到项目属性 -> 配置属性 -> C/C++ -> 预处理器 -> 预处理器定义

关于从 <sys/stat.h> 调用 stat 失败并出现 "Value too large for defined data type"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13893580/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com