c - _LARGEFILE_SOURCE 和 _FILE_OFFSET_BITS=64 有什么区别?

标签 c linux linux-from-scratch

我了解 -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).

因此该宏专门使 fseekoftello 可用。 _FILE_OFFSET_BITS 设置本身并不能使这些功能可用。

(请注意,如果您使用的是 C 的 GNU 方言,即 GCC 的默认方言,您可能不需要显式定义 _LARGEFILE_SOURCE。如果您使用 -std=c99,则需要这样做 例如。)

关于c - _LARGEFILE_SOURCE 和 _FILE_OFFSET_BITS=64 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14184031/

相关文章:

c - scanf 相当于 c 中的箭头键支持

c - 32x32 乘加优化

linux - 打开套接字或使用解析器时权限被拒绝

linux - 构建 LFS - 5.7 : Need linker with . init_array/.fini_array 支持时出错

c - 为什么这个简单的 PWM 在 xc8 中不起作用

python - 在 windows 和 linux 上获取 gpu 供应商名称

linux - fsync 不适用于 ext3 或 ext4 系统

c - 如何在 Linux 上从汇编代码中调用 c 库?

linux - 我如何将 yacc 更改为 bison (LFS)

c - c中的段错误