__USE_FILE_OFFSET64 与 _FILE_OFFSET_BITS=64 [英] __USE_FILE_OFFSET64 vs. _FILE_OFFSET_BITS=64

查看:38
本文介绍了__USE_FILE_OFFSET64 与 _FILE_OFFSET_BITS=64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试维护可在许多不同系统上编译的代码.我见过十几种不同的请求 lseek 需要 64 位的方法.有些系统使用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.

这一切有什么标准吗?

推荐答案

IEEE Std 1003.1-2004 中的 getconf 值(以及 IEEE Std 1003.1-2008;另请参见这些文档中的示例"部分).没有指定实际的编译器选项(甚至可能没有定义).

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.

然而,autoconf 中的 AC_SYS_LARGEFILE 宏并没有尝试使用它——它只是尝试 -n32 用于 IRIX,-D_FILE_OFFSET_BITS=64(应该适用于大多数系统)和 -D_LARGE_FILES=1(显然适用于 AIX).还有一个对向单个 UNIX 规范添加对任意文件大小的支持(旧的规范草案,然后部分包含在 POSIX.1 规范中)在 autoconf 源中.

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.

至于手动定义 __USE_FILE_OFFSET64,不确定这是否真的是一个正确的解决方案——双下划线宏是为系统头文件保留的,而且很可能有一些条件定义依赖于其他定义.

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.

这篇关于__USE_FILE_OFFSET64 与 _FILE_OFFSET_BITS=64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆