diff --git a/components/libc/posix/io/stdio/libc.c b/components/libc/posix/io/stdio/libc.c index ebdc3a5..74410d3 100644 --- a/components/libc/posix/io/stdio/libc.c +++ b/components/libc/posix/io/stdio/libc.c @@ -34,6 +34,7 @@ int libc_system_init(void) INIT_COMPONENT_EXPORT(libc_system_init); #if defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) +#define NEWLIB_VERSION_NUM (__NEWLIB__ * 10000U + __NEWLIB_MINOR__ * 100U + __NEWLIB_PATCHLEVEL__) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; int libc_stdio_set_console(const char* device_name, int mode) @@ -89,8 +90,9 @@ int libc_stdio_set_console(const char* device_name, int mode) _GLOBAL_REENT->_stdout = std_console; _GLOBAL_REENT->_stderr = std_console; } - +#if (NEWLIB_VERSION_NUM < 30400U) || (NEWLIB_VERSION_NUM >= 40000U && NEWLIB_VERSION_NUM < 40200U) _GLOBAL_REENT->__sdidinit = 1; +#endif } if (std_console)