Yes, do define it.
There is no drawback on using -D_FILE_OFFSET_BITS=64
on a 64-bit platform. On 32-bit platform if you're doing something that could potentially need to seek/tell anything on files where the offsets exceed 2³¹, you need this one or be prepared to use the separate 64-bit functions.
The reason why the behaviour isn't the default is that the C standard and POSIX specifies that long int
be used for various functions - on 32-bit Unixen, long int
can usually hold a value up to 2³¹ only. Now, the use of -D_FILE_OFFSET_BITS=64
would guarantee that the code that uses lseek
, ftello
etc, would continue to work in a 32-bit system as it would in a 64-bit system.
Quoting GLibc feature test macros:
Macro: _FILE_OFFSET_BITS
This macro determines which file system interface shall be used, one replacing the other. Whereas _LARGEFILE64_SOURCE
makes the 64 bit interface available as an additional interface, _FILE_OFFSET_BITS
allows the 64 bit interface to replace the old interface.
[...]
If the macro is defined to the value 64, the large file interface replaces the old interface. I.e., the functions are not made available under different names (as they are with _LARGEFILE64_SOURCE
). Instead the old function names now reference the new functions, e.g., a call to fseeko now indeed calls fseeko64.
This macro should only be selected if the system provides mechanisms for handling large files. On 64 bit systems this macro has no effect since the *64
functions are identical to the normal functions.
And fseeko(3)
man pages:
On some architectures, both off_t
and long
are 32-bit types, but defining _FILE_OFFSET_BITS
with the value 64 (before including any header files) will turn off_t
into a 64-bit type.