Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

v26.06.9 not compiling on FreeBSD 15.1 (ccan/ccan/asort/asort.h with a solution)

未关闭 适合新手
#9,616 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
build-system

调研方向

冲突位于 ccan/ccan/asort/asort.h,其中本地的 qsort_r 声明与 FreeBSD 15.1 的 /usr/include/stdlib.h 所定义的宏发生冲突。请先阅读该头文件中 GNU 签名的分支,然后在 FreeBSD 上编译 ccan/ccan/asort/asort.c 以复现问题(Makefile 第 1106 行的规则会失败)。完成标准是:该文件能在 FreeBSD 15.1 上编译,并且在 Linux 上仍能构建,Linux 使用 GNU 版的 qsort_r 声明。在采用报告者提出的 __FreeBSD_version 守卫之前,请先将其与 FreeBSD 实际的签名进行核对。

由索引模型根据 Issue 内容生成。

描述

A recent change in ccan/ccan/asort/asort.h makes v26.06.9 not compilable on FreeBSD 15.1:

cc ccan/ccan/asort/asort.c
In file included from ccan/ccan/asort/asort.c:1:
ccan/ccan/asort/asort.h:30:6: error: expected identifier or '('
   30 | void qsort_r(void *base, size_t nmemb, size_t size,
      |      ^
/usr/include/stdlib.h:367:5: note: expanded from macro 'qsort_r'
  367 |     __generic(arg5, int (*)(void *, const void *, const void *),        \
      |     ^
/usr/include/sys/cdefs.h:228:2: note: expanded from macro '__generic'
  228 |         _Generic(expr, t: yes, default: no)
      |         ^
1 error generated.
gmake: *** [Makefile:1106: ccan-asort.o] Error 1

I think you might need something like this:

diff --git a/ccan/ccan/asort/asort.h b/ccan/ccan/asort/asort.h
index 4f5ab2402..d30e65a61 100644
--- a/ccan/ccan/asort/asort.h
+++ b/ccan/ccan/asort/asort.h
@@ -4,6 +4,7 @@
 #include "config.h"
 #include <ccan/order/order.h>
 #include <stdlib.h>
+#include <sys/param.h>
 
 /**
  * asort - sort an array of elements
@@ -27,8 +28,10 @@ _asort((base), (num), sizeof(*(base)),                                       \
  * first libc include — we can't control our includers, so declare it
  * ourselves (the configurator only sets this where this GNU signature
  * was detected). */
+#if !defined(__FreeBSD__) || __FreeBSD_version < 1400000
 void qsort_r(void *base, size_t nmemb, size_t size,
             int (*compar)(const void *, const void *, void *), void *arg);
+#endif
 #define _asort(b, n, s, cmp, ctx) qsort_r(b, n, s, cmp, ctx)
 #else
 void _asort(void *base, size_t nmemb, size_t size,
主要语言
C
星标
3.1k
派生
1k
平均合并
4 天 4 小时
30 天内合并 PR
27

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ElementsProject/lightning 的其他 Issue

查看 ElementsProject/lightning 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。