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
相关推荐
这个DBA有点耶2 天前
MVCC深入:Read View、版本链与快照读——InnoDB并发控制的内核
数据库·mysql·架构
DBA_G2 天前
从地面到云霄:GBase数据库在民航三大场景的落地实践
数据库
自由能燃气设备2 天前
商用全预混低氮冷凝锅炉免费方案vs付费方案对比+选型避坑指南
大数据·数据库·人工智能
科创致远2 天前
科创致远 ESOP 系统核心效能与实战价值展示
大数据·数据库·人工智能·精益工程
IT大白鼠2 天前
Redis 系列 · 第 01 篇——认知入门:Redis 是什么
redis·nosql
彧azz2 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
2601_962218612 天前
万象生鲜系统称重自动多退少补算法解决生鲜非标品痛点
大数据·数据库·人工智能·python·算法
张洛闻Eren2 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github
于平安2 天前
MySQL-触发器
数据库·mysql
白远山2 天前
上海24小时自助健身房解决方案实战指南与经验分享
java·数据库·架构·需求分析