是什么_LARGEFILE_SOURCE和_FILE_OFFSET_BITS = 64之间的区别?
据我所知, -D_FILE_OFFSET_BITS = 64
引起 off_t
是64位。那么,是什么 -D_LARGEFILE_SOURCE
做到这一点还没有被 -D_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?
glibc的Feature测试宏文档状态:
The GLIBC Feature test macros documentation states:
_LARGEFILE_SOURCE
结果
如果该宏定义了一些额外的功能,可它纠正所有previous标准一些缺点。具体地,功能fseeko和ftello可用。如果没有这些功能的ISO C接口(fseek的,FTELL)和低级别的POSIX接口(lseek的)之间的差异会导致问题。
_LARGEFILE_SOURCE
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.
本宏介绍,作为大文件支持扩展(LFS)的一部分。
This macro was introduced as part of the Large File Support extension (LFS).
所以,宏观专门让 fseeko
和 ftello
可用。 _FILE_OFFSET_BITS
设置本身并不能使这些功能。
So that macro specifically makes fseeko
and ftello
available. _FILE_OFFSET_BITS
settings alone don't make these functions available.
(注意,如果你使用C,与GCC默认的GNU话,你可能不需要明确定义 _LARGEFILE_SOURCE
。怎么做,如果你使用 -std = C99
的实例。)
(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.)