canard.c 5.0.0: static random() conflicts with newlib's random() (fails to build on ESP-IDF)

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

还没有人认领这个 Issue。

评估

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

调研方向

打开canard.c,检查random()的定义及其三个调用位置,包括chance()中的调用。使用报告中的idf.py build命令,在包含libcanard 5.0.0的ESP-IDF项目中重现构建失败。当组件在没有冲突的random()声明的情况下构建成功时,即为完成。

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

描述

canard.c in v5.0.0 defines static uint64_t random(canard_t* const self, const uint64_t bound)
(line 130). On ESP-IDF this fails to compile because newlib's <stdlib.h> declares
long random(void);, and it is pulled in indirectly by the headers canard.c includes.
v4.0.0 has no function with this name. This breaks the ESP registry package
opencyphal/libcanard 5.0.0.

Error (ESP-IDF v5.3.1, gcc 13.2.0, -std=gnu17 -D_GNU_SOURCE):

canard.c:130:17: error: conflicting types for 'random'; have 'uint64_t(canard_t * const, const uint64_t)'

Reproduce: in an ESP-IDF project add opencyphal/libcanard: "^5.0.0" to
main/idf_component.yml and run idf.py build.

Suggested fix: rename the helper, e.g. to canard_random. It appears 4 times in
canard.c: lines 130 (definition), 136 (chance()), 1933 and 1988. A new release would be
needed for the ESP registry package to pick it up.

主要语言
C
星标
451
派生
220
平均合并
2 天 9 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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