__USE_FILE_OFFSET64 vs. _FILE_OFFSET_BITS=64

拜拜、爱过 提交于 2019-12-03 06:47:55

问题


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?


回答1:


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.




回答2:


In features.h, you see the relation between _FILE_OFFSET_BITS and __USE_FILE_OFFSET64.

#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64    1
#endif

So, only _FILE_OFFSET_BITS is meant for the users.



来源:https://stackoverflow.com/questions/4357570/use-file-offset64-vs-file-offset-bits-64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!