I'm using the function
int open (const char *filename, int flags[, mode_t mode])
in my code to open files.
file->fd = open(filename, O_RDWR | O_BINARY);
if (file->fd == -1) {
perror("cannot open file");
return -1;
}
My code is running well on GNU/linux (64bit) but on Windows (64bit) I can't open file larger than 4Go. I would understand I have this kind of problem on 32bit systems, but I do not understand why it is the case on Windows 64bit. I've read documentation and there is the function open64. However this function is dedicated to 32bit systems which is not my case (Don't care about 32bits systems).
I don't think this topic is a doublon because all the topics I've read explain how to use the macros -D_FILE_OFFSET_BITS=64
or -D_LARGEFILE_SOURCE=1
, but again it is for 32bit system.
I've also read that there's a flag: O_LARGEFILE to do it. But apparently it is a bad practice as it should be done automatically.
I'm stuck and I do not want to change all my code to use fopen
, so if anyone has a solution for opening large file with open in Windows it could be great.