mac上编译redis ,报错fstat64

mac上编译redis ,报错fstat64

                                void
replication.c:1289:31: error: variable has incomplete type 'struct stat64'
            struct redis_stat buf;
                              ^
replication.c:1289:20: note: forward declaration of 'struct stat64'
            struct redis_stat buf;
                   ^
./config.h:45:20: note: expanded from macro 'redis_stat'
#define redis_stat stat64
                   ^
replication.c:1336:21: error: call to undeclared function 'fstat64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

因为 macOS 的 fstat 函数已经默认支持大文件(即自动处理大于 2GB 的文件),因此不需要使用 fstat64

查看 src/config.h文件

可以看到关于fstat64的引用

#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
#define redis_fstat fstat64
#define redis_stat stat64
#else
#define redis_fstat fstat
#define redis_stat stat
#endif

这里是走了if分支,只要修改代码,让走else分支就可以了。

if 中主要定义了两个条件,__APPLE__mac上肯定是存在的,另一个条件MAC_OS_X_VERSION_10_6不存在,就走了if分支。因此我们定义MAC_OS_X_VERSION_10_6就可以走到else分支了。

解决方法就是在这段代码的上面增加MAC_OS_X_VERSION_10_6的定义

#define MAC_OS_X_VERSION_10_6
#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
#define redis_fstat fstat64
#define redis_stat stat64
#else
#define redis_fstat fstat
#define redis_stat stat
#endif
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值