Given tmp.c:
鉴于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;
}
I get Error calling stat: Value too large for defined data type
, when I run the program on a large file (~2.5 Gb).
当我在一个大文件(~2.5 Gb)上运行程序时,我得到了错误调用stat:对于定义的数据类型来说,值太大了。
4 个解决方案
#1
7
One needs to #define _FILE_OFFSET_BITS 64
: either add it before you #include <sys/stat.h>
or define it in your platform-specific way e.g., for gcc see -D option; for Visual Studio go to project properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
一个需要定义_FILE_OFFSET_BITS 64:在包含
#2
2
If others have this problem and the _FILE_OFFSET_BITS 64
before #include "sys/stat.h"
did not solve it yet, just move it in front of all other include's too. I did not find out which headers also depended on this but it solved the problem.
如果其他人有这个问题,而_FILE_OFFSET_BITS 64前面包含“sys/stat”。h“没有解决它,只是把它移到所有其他的include前面。我没有发现哪个头也依赖于这个,但它解决了这个问题。
#3
0
Have a look in to this link . It provides you the way to handle such issue.
看看这个链接。它为您提供了处理此类问题的方法。
This is typically done by defining -D_FILE_OFFSET_BITS=64 or some such. It is system dependent. Once done and once switched into this new mode most programs will support large files just fine.
这通常是通过定义-D_FILE_OFFSET_BITS=64来完成的。这是系统的依赖。一旦完成,一旦切换到这种新的模式,大多数程序都会支持大文件。
#4
0
you are able to remove this limitation by including header file config.h in your program. and this is not necessary to include whole file but you are also able to put one macro #define _FILE_OFFSET_BITS 64 to remove limitation.
您可以通过包含头文件配置来移除这个限制。在您的程序。这并不需要包含整个文件,但是您也可以使用一个宏#define _FILE_OFFSET_BITS 64来移除限制。
#1
7
One needs to #define _FILE_OFFSET_BITS 64
: either add it before you #include <sys/stat.h>
or define it in your platform-specific way e.g., for gcc see -D option; for Visual Studio go to project properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
一个需要定义_FILE_OFFSET_BITS 64:在包含
#2
2
If others have this problem and the _FILE_OFFSET_BITS 64
before #include "sys/stat.h"
did not solve it yet, just move it in front of all other include's too. I did not find out which headers also depended on this but it solved the problem.
如果其他人有这个问题,而_FILE_OFFSET_BITS 64前面包含“sys/stat”。h“没有解决它,只是把它移到所有其他的include前面。我没有发现哪个头也依赖于这个,但它解决了这个问题。
#3
0
Have a look in to this link . It provides you the way to handle such issue.
看看这个链接。它为您提供了处理此类问题的方法。
This is typically done by defining -D_FILE_OFFSET_BITS=64 or some such. It is system dependent. Once done and once switched into this new mode most programs will support large files just fine.
这通常是通过定义-D_FILE_OFFSET_BITS=64来完成的。这是系统的依赖。一旦完成,一旦切换到这种新的模式,大多数程序都会支持大文件。
#4
0
you are able to remove this limitation by including header file config.h in your program. and this is not necessary to include whole file but you are also able to put one macro #define _FILE_OFFSET_BITS 64 to remove limitation.
您可以通过包含头文件配置来移除这个限制。在您的程序。这并不需要包含整个文件,但是您也可以使用一个宏#define _FILE_OFFSET_BITS 64来移除限制。