summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorloremmoqi <[email protected]>2025-10-13 11:45:22 +0800
committerGitHub <[email protected]>2025-10-13 11:45:22 +0800
commit17a796af24f4c053f4137100f2c9a381efed4cee (patch)
tree963c820f25450415c546b619e32b8f76132d6c9b /components/libc
parentae3f52de68fd3459b956629a2f6329820e67ffae (diff)
fix(stdio): ensure compatibility with newlib <3.4.0 by handling removed __sdidinit (#10791)
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/posix/io/stdio/stdio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/libc/posix/io/stdio/stdio.c b/components/libc/posix/io/stdio/stdio.c
index 98816c1f28..06d341d722 100644
--- a/components/libc/posix/io/stdio/stdio.c
+++ b/components/libc/posix/io/stdio/stdio.c
@@ -104,8 +104,12 @@ int rt_posix_stdio_set_console(const char* device_name, int mode)
_GLOBAL_REENT->_stderr = std_console;
}
-#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 >= 3.4.0 or small reent version: no __sdidinit field */
+ /* Do nothing */
+#else
+ /* Older newlib versions (typically < 3.4.0) still define __sdidinit */
+ _GLOBAL_REENT->__sdidinit = 1;
#endif
}