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
相关推荐
声声codeGrandMaster41 分钟前
django之账号管理功能
数据库·后端·python·django
明似水1 小时前
macOS 更新后找不到钥匙串访问工具的解决方案
macos
互联网搬砖老肖1 小时前
运维打铁:Centos 7 安装 redis_exporter 1.3.5
运维·redis·centos
Elastic 中国社区官方博客1 小时前
使用 LangGraph 和 Elasticsearch 构建强大的 RAG 工作流
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
AscendKing1 小时前
mongo客户端操作mongodb记录
数据库·mongodb
我的golang之路果然有问题1 小时前
案例速成GO+redis 个人笔记
经验分享·redis·笔记·后端·学习·golang·go
LCY1331 小时前
python 与Redis操作整理
开发语言·redis·python
千千寰宇2 小时前
[设计模式/Java] 设计模式之解释器模式【27】
数据库·设计模式
BXCQ_xuan2 小时前
Typecho博客网站头部SEO优化完整指南
运维·服务器·数据库·php·web
施嘉伟2 小时前
Oracle 11g RAC手动打补丁详细步骤
数据库·oracle