我了解 -D_FILE_OFFSET_BITS=64
导致 off_t
为 64 位。那么 -D_LARGEFILE_SOURCE
做了哪些 -D_FILE_OFFSET_BITS=64
尚未完成的事情?这些定义究竟做了什么?
最佳答案
GLIBC Feature test macros文档状态:
_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.This macro was introduced as part of the Large File Support extension (LFS).
因此该宏专门使 fseeko
和 ftello
可用。 _FILE_OFFSET_BITS
设置本身并不能使这些功能可用。
(请注意,如果您使用的是 C 的 GNU 方言,即 GCC 的默认方言,您可能不需要显式定义 _LARGEFILE_SOURCE
。如果您使用 -std=c99,则需要这样做
例如。)
关于c - _LARGEFILE_SOURCE 和 _FILE_OFFSET_BITS=64 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14184031/