Large file support with C
From Notes_Wiki
Large file support with C
By default on 32-bit operating systems fprintf, fwrite etc. use integer for maintaining location of next read/write operation in file. Hence max 2GB can be read or written using fprintf, fwrite, etc. ls -lh may show the same value as 2.1GB on some operating systems.
In order for these functions to write files bigger then 2GB large file support should be enabled. To enable large file support define following variables in source code.
#define _LARGEFILE_SOURCE _ #define FILE_OFFSET_BITS 64
Same can be achieved during compilation using:
gcc `getconf LFS_CFLAGS` example.c -o example
Use 'getconf LFS_CFLAGS' command to see which flags work for given compiler to make it support large files. For example on 64-bit systems 'getconf LFS_CFLAGS' does not returns anything, as nothing special is required for supporting large files on 64-bit systems.