Skip to content

Commit 17a796a

Browse files
authored
fix(stdio): ensure compatibility with newlib <3.4.0 by handling removed __sdidinit (#10791)
1 parent ae3f52d commit 17a796a

File tree

1 file changed

+6
-2
lines changed
  • components/libc/posix/io/stdio

1 file changed

+6
-2
lines changed

components/libc/posix/io/stdio/stdio.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ int rt_posix_stdio_set_console(const char* device_name, int mode)
104104
_GLOBAL_REENT->_stderr = std_console;
105105
}
106106

107-
#if (NEWLIB_VERSION_NUM < 30400U) || (NEWLIB_VERSION_NUM >= 40000U && NEWLIB_VERSION_NUM < 40300U)
108-
_GLOBAL_REENT->__sdidinit = 1; /* __sdidinit is obselete */
107+
#if defined(_REENT_SMALL) || !defined(__sdidinit)
108+
/* Newlib >= 3.4.0 or small reent version: no __sdidinit field */
109+
/* Do nothing */
110+
#else
111+
/* Older newlib versions (typically < 3.4.0) still define __sdidinit */
112+
_GLOBAL_REENT->__sdidinit = 1;
109113
#endif
110114
}
111115

0 commit comments

Comments
 (0)