Given 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).
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With