mac上编译redis ,报错fstat64

mac上编译redis ,报错fstat64

shell 复制代码
                                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的定义

c 复制代码
#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
相关推荐
坚定信念,勇往无前2 小时前
mongodb的日志分割
数据库·mongodb
oradh5 小时前
Oracle TX 锁 Mode 4(Share)问题排查总结
数据库·oracle·tx 锁 mode 4·oracle tx 锁
yi.Ist6 小时前
数据定义语言-DDL操作
数据库·学习·mysql·oracle·大海豚
2601_963282777 小时前
工程项目、政企采购为什么优先选择对讲机批量采购?
数据库
Doraemomo8 小时前
SQLite数据库
数据库·sqlite
云贝教育-郑老师8 小时前
MySQL 的“黑匣子“:Performance Schema 把数据库内部变成一张可查的表
数据库·mysql
这个DBA有点耶10 小时前
同城双活落地的三座山:网络延迟、脑裂预防、反向同步
数据库·架构·dba
青春之我_XP10 小时前
MySQL 常用日期函数 实战指南
数据库·sql·mysql·数据分析·数据库开发·日期函数
Nturmoils10 小时前
sys_dump 备了库,角色和权限别漏在外面
数据库