linux c之关于 Value too large for defined data type的解决

//#define _FILE_OFFSET_BITS 64
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>

//stat file >2G
//Error calling stat: Value too large for defined data type
//http://stackoverflow.com/questions/13893580/calling-stat-from-sys-stat-h-faills-with-value-too-large-for-defined-data-typ
int main(int argc, const char *argv[])
{
    struct stat st;
#ifdef _FILE_OFFSET_BITS
    printf("_FILE_OFFSET_BITS=%d\n",_FILE_OFFSET_BITS);
#endif
    if (stat(argv[1], &st) != 0)
    {
        perror("Error calling stat");
    }
    printf("stat ok\n");

    return 0;
}

当stat file >2G 在linux会出现

Error calling stat: Value too large for defined data type
解决方法是:

#define _FILE_OFFSET_BITS 64
#include <sys/stat.h>
qt pro配置

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.c

#http://stackoverflow.com/questions/3348711/add-a-define-to-qmake-with-a-value
# gcc -D_FILE_OFFSET_BITS=64
DEFINES += "_FILE_OFFSET_BITS=64"


include(deployment.pri)
qtcAddDeployment()




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值