瀏覽代碼

[libc] Fix the fputc issue when use microlib.

Bernard Xiong 6 年之前
父節點
當前提交
b49859582a
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      components/libc/compilers/armlibc/stubs.c

+ 4 - 3
components/libc/compilers/armlibc/stubs.c

@@ -313,17 +313,18 @@ int system(const char *string)
 
 int fputc(int c, FILE *f) 
 {
-    char ch = c;
+    char ch[2] = {0};
 
-    rt_kprintf(&ch);
+    ch[1] = c;
+    rt_kprintf(&ch[0]);
     return 1;
 }
 
 int fgetc(FILE *f) 
 {
+#ifdef RT_USING_POSIX
     char ch;
 
-#ifdef RT_USING_POSIX
     if (libc_stdio_read(&ch, 1) == 1)
         return ch;
 #endif