What is the difference between _LARGEFILE_SOURCE and _FILE_OFFSET_BITS=64?


I understand that -D_FILE_OFFSET_BITS=64 causes off_t to be 64bits. So what does -D_LARGEFILE_SOURCE do that isn’t already done by -D_FILE_OFFSET_BITS=64? What do these definitions do exactly?


The GLIBC Feature test macros documentation states:

If this macro is defined some extra functions are available which rectify a few shortcomings in all previous standards. Specifically, the functions fseeko and ftello are available. Without these functions the difference between the ISO C interface (fseek, ftell) and the low-level POSIX interface (lseek) would lead to problems.

This macro was introduced as part of the Large File Support extension (LFS).

So that macro specifically makes fseeko and ftello available. _FILE_OFFSET_BITS settings alone don’t make these functions available.

(Note that if you’re using a GNU dialect of C, the default with GCC, you might not need to explicitly define _LARGEFILE_SOURCE. You do if you use -std=c99 for instance.)

Answered By – Mat

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published