Просмотр исходного кода

fix(stdio): ensure compatibility with newlib <3.4.0 by handling removed __sdidinit (#10791)

loremmoqi 3 месяцев назад
Родитель
Сommit
17a796af24
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      components/libc/posix/io/stdio/stdio.c

+ 6 - 2
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
     }