fix: make QEMU-VExpress-A9 example compatible with newlib 12.x by han…#10785
fix: make QEMU-VExpress-A9 example compatible with newlib 12.x by han…#10785loremmoqi wants to merge 2 commits intoRT-Thread:masterfrom loremmoqi:fix-bug-newlib
Conversation
…dling removed __sdidinit
|
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_libcReviewers: @GorrayLi @mysterywolf Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-10-11 00:26 CST)
📝 Review Instructions
|
| #if (NEWLIB_VERSION_NUM < 30400U) || (NEWLIB_VERSION_NUM >= 40000U && NEWLIB_VERSION_NUM < 40300U) | ||
| _GLOBAL_REENT->__sdidinit = 1; /* __sdidinit is obselete */ | ||
| #if defined(_REENT_SMALL) || !defined(__sdidinit) | ||
| // newlib 新版本没有 __sdidinit |
|
|
||
| #if (NEWLIB_VERSION_NUM < 30400U) || (NEWLIB_VERSION_NUM >= 40000U && NEWLIB_VERSION_NUM < 40300U) | ||
| _GLOBAL_REENT->__sdidinit = 1; /* __sdidinit is obselete */ | ||
| #if defined(_REENT_SMALL) || !defined(__sdidinit) |
There was a problem hiding this comment.
这里的宏判断需要有更清晰的解释,哪个版本有,哪个版本取消。或者说之前的版本方式会更适合些?请给出更多的注释吧,谢谢
…dling removed __sdidinit
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
在使用新版本的 newlib 时,RT-Thread 的 QEMU-VExpress-A9 示例在编译过程中出现错误:error: 'struct _reent' has no member named '__sdidinit'。这是因为新版 newlib 移除了 __sdidinit 成员,导致 RT-Thread 的 stdio.c 代码不兼容。本 PR 修复了这一问题,确保示例在新版 newlib 下能够正常编译。
你的解决方案是什么 (what is your solution)
在 components/libc/posix/io/stdio.c 中,添加了条件编译宏以适配 newlib 的版本差异:
#if defined(_REENT_SMALL) || !defined(__sdidinit)
// newlib 新版本没有 __sdidinit
#else
_GLOBAL_REENT->__sdidinit = 1;
#endif
此修改确保在新版 newlib 下,标准输入输出初始化代码能够正确编译,同时保持对旧版 newlib 的兼容性。
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up