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