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
相关推荐
倔强的石头_7 小时前
《Kingbase护城河》——猎捕慢查询:执行计划的微观解析与索引调优实战
数据库
SelectDB9 小时前
Apache Doris Python UDF:让 SQL 直接调用 Python 生态,支撑 Agent 时代复杂业务逻辑
大数据·数据库·python
Mintimate10 小时前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
jiayou641 天前
KingbaseES 表级与列级加密完全指南
数据库·后端
fthux2 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
用户3074596982072 天前
Redis 延时队列详解
redis
GBASE2 天前
G术时刻 |GBase 8s数据库事务并发控制之封锁技术介绍(下)
数据库
烤代码的吐司君2 天前
Redis 数据结构 ZSet, BIT, HyperLogLog,Geo 空间数据
redis·后端
xiezhr3 天前
逛GitHub发现了一款免费的带AI功能的数据库管理工具
数据库·ai编程·dba
吃糖的小孩4 天前
给 QQ AI 机器人设计“可控记忆”:会话摘要、手动长期记忆与角色卡边界
数据库