__USE_FILE_OFFSET64 与 _FILE_OFFSET_BITS=64
我正在尝试维护在许多不同系统上编译的代码。我见过十几种不同的方式来请求需要 64 位的 lseek
。有些系统使用 lseek64
,有些系统使用 lseeko
,有些系统要求您定义 _FILE_OFFSET_BITS=64
,现在我刚刚找到了一个新系统,它需要您定义__USE_FILE_OFFSET64
。
这一切有什么标准吗?
I am trying to maintain code that compiles on lots of different systems. I've seen a dozen different ways of asking for lseek
that takes 64-bits. Some systems use lseek64
, some use lseeko
, some require that you define _FILE_OFFSET_BITS=64
, and now I just found a new one that requires that you define __USE_FILE_OFFSET64
.
Is there any standard to all of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IEEE Std 1003.1-2004 中有 getconf 值(以及IEEE Std 1003.1-2008 中的较新设置;另请参阅示例这些文件中的部分)。未指定实际的编译器选项(甚至可能没有定义)。
但是,autoconf 中的
AC_SYS_LARGEFILE
宏不会尝试使用此选项 - 它仅尝试使用-n32
来表示 IRIX,-D_FILE_OFFSET_BITS=64
(其中应该适用于大多数系统)和-D_LARGE_FILES=1
(显然适用于 AIX)。还参考了向单一 UNIX 规范添加对任意文件大小的支持 (较旧的规范草案,后来部分包含在 POSIX.1 规范中)。至于手动定义
__USE_FILE_OFFSET64
,不确定这是否真的是一个正确的解决方案 ——双下划线宏是为系统头保留的,并且很可能存在一些依赖于其他定义的条件定义。There are getconf values in IEEE Std 1003.1-2004 (and a newer set in IEEE Std 1003.1-2008; see also the EXAMPLES section in those documents). Actual compiler options (which might not even be defines) are not specified.
However, the
AC_SYS_LARGEFILE
macro in autoconf does not try to use this — it tries just-n32
for IRIX,-D_FILE_OFFSET_BITS=64
(which should work for most systems) and-D_LARGE_FILES=1
(apparently for AIX). There is also a reference to Adding Support for Arbitrary File Sizes to the Single UNIX Specification (an older spec draft which was then partially included in the POSIX.1 spec) in autoconf sources.As for defining
__USE_FILE_OFFSET64
manually, not sure if this is really a correct solution — double-underscore macros are reserved for system headers, and most likely there is some conditional definition there which depends on other defines.在
features.h
中,您可以看到_FILE_OFFSET_BITS
和__USE_FILE_OFFSET64
之间的关系。因此,只有
_FILE_OFFSET_BITS
适合用户。In
features.h
, you see the relation between_FILE_OFFSET_BITS
and__USE_FILE_OFFSET64
.So, only
_FILE_OFFSET_BITS
is meant for the users.