在文件>上没有-D_FILE_OFFSET_BITS = 64的off_t中2GB [英] off_t without -D_FILE_OFFSET_BITS=64 on a file > 2GB

查看:116
本文介绍了在文件>上没有-D_FILE_OFFSET_BITS = 64的off_t中2GB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1-我想知道,如果我尝试读取大小大于2GB的文件,而没有使用off_t并使用off_t选项和off_t使用第二个函数来编译程序,那将会是什么问题呢? a href ="https://stackoverflow.com/questions/8236/how-do-you-determine-the-size-of-a-file-in-c/8384#8384">此页面?会出现段错误吗?

1- I'm wondering, what would be the problem if I try to read a file greater than 2GB in size without compiling my program with the option -D_FILE_OFFSET_BITS=64 using off_t and using the second function on this page? would it segfault?

2-我打算使用有什么问题吗?

推荐答案

  1. stat()将失败,并设置errno 在这种情况下增加到ELOWFLOW.这是 linux手册页怎么说

  1. stat() will fail, and errno set to EOVERFLOW in that case. Here's what the linux man page says

EOVERFLOW  stat()) path refers to a file whose size cannot be
represented in the type off_t.  This can occur when an application

已编译 在没有-D_FILE_OFFSET_BITS = 64的32位平台上调用stat() 文件大小超过(2<< 31)-1位.

compiled on a 32-bit platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size exceeds (2<<31)-1 bits.

  • 如果使用-D_FILE_OFFSET_BITS = 64进行编译,则无需使用off64_t. 您可以继续使用off_t,它将变为64位,并且所有功能 处理文件和文件大小将变得可识别64位.
  • If you compile with -D_FILE_OFFSET_BITS=64 , you don't need to use off64_t though. You can just continue to use off_t , it'll become 64 bit, and all the functions dealing with files and file sizes will become 64 bit aware.
  • 这篇关于在文件&gt;上没有-D_FILE_OFFSET_BITS = 64的off_t中2GB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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