1- I'm wondering, what would be the problem if I try to read a file greater than 2GB
in size without compiling my program with the option -D_FILE_OFFSET_BITS=64
using off_t
and using the second function on this page? would it segfault?
2- I'm planning to use this implementation with off64_t
and
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64
Would there be any problem?
stat() will fail, and errno set to EOVERFLOW in that case. Here's what the linux man page says
Never use
off64_t
explicitly. Always build your programs with 64 bit file offsets on systems where it's necessary to explicitly specify this. Failure to do so is a major bug which your users will end up hating. No idea why it's not default on modern systems...It oughtn't segfault, but the size of the file won't be reported correctly.