gpt4 book ai didi

c - lseek EOVERFLOW 错误处理

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:24:44 26 4
gpt4 key购买 nike

我注意到,当我尝试寻找比 off_t 所能代表的更多的字节时,我得到了EOVERFLOW 错误。我怎样才能在 off_t 中寻找更大的数字?

最佳答案

启用large file support .

In a nutshell for using LFS you can choose either of the following:

  • Compile your programs with "gcc -D_FILE_OFFSET_BITS=64". This forces all file access calls to use the 64 bit variants. Several types change also, e.g. off_t becomes off64_t. It's therefore important to always use the correct types and to not use e.g. int instead of off_t. For portability with other platforms you should use getconf LFS_CFLAGS which will return -D_FILE_OFFSET_BITS=64 on Linux platforms but might return something else on e.g. Solaris. For linking, you should use the link flags that are reported via getconf LFS_LDFLAGS. On Linux systems, you do not need special link flags.
  • Define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE. With these defines you can use the LFS functions like open64 directly.
  • Use the O_LARGEFILE flag with open to operate on large files.

关于c - lseek EOVERFLOW 错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11286515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com