如何用C实现putchar来支持RTS?

问题描述 投票:0回答:1

我正在为 esp32s3 SoC 实现一个最小的 Ada RTS。目前,我遇到了一个错误,事实证明该错误对我提出的每一个解决方案都无效。它声称 putchar 未定义:

Link
   [link]         blinky.adb
GNU ld (GNU Binutils) 2.42
  Supported emulations:
   elf32xtensa
blinky.o
b__blinky.o
/Users/joe/Development/Ada_Xtensa_ESP32/esp32s3_hal/lib/libEsp32s3_Hal.a
/Users/joe/Development/Ada_Xtensa_ESP32/light_xtensa_esp/adalib/libgnat.a
/Users/joe/.local/share/alire/builds/hal_0.3.1_58bb6bd7/8772a4cbfba2091702a44c6fad50eea0509f0fc415885a6c2d23a26ec134eb8a/lib/libhal.a
/Users/joe/Development/Ada_Xtensa_ESP32/light_xtensa_esp/adalib/libgnat.a
/Users/joe/.local/share/alire/toolchains/gnat_xtensa_esp32_elf_14.2.1_c70145cf/bin/../lib/gcc/xtensa-esp32-elf/14.2.0/../../../../xtensa-esp32-elf/bin/ld: /Users/joe/Development/Ada_Xtensa_ESP32/light_xtensa_esp/adalib/libgnat.a(s-textio.o): in function `system__text_io__put':
s-textio.adb:(.text.system__text_io__put+0x6): undefined reference to `putchar'

但是,当我实现 putchar 时,它会抱怨错误:

   [C]            main.c
/Users/Joe/Development/Ada_Xtensa_ESP32/esp32s3_hal/src/main.c:12:6: error: conflicting types for built-in function 'putchar'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
   12 | void putchar(int c)

我尝试取消定义putchar,甚至添加了-fno-builtin GCC选项,但我仍然遇到相同的错误。

compiler-errors runtime linker-errors ada built-in
1个回答
0
投票
   [C]            main.c
/Users/Joe/Development/Ada_Xtensa_ESP32/esp32s3_hal/src/main.c:12:6: error: conflicting types for built-in function 'putchar'; expected 'int(int)' [-Werror=builtin-declaration-mismatch]
   12 | void putchar(int c)

在该消息的右侧显示

error: conflicting types for built-in function 'putchar';
   expected 'int(int)'```

所以我认为你应该尝试

int putchar(int c)

© www.soinside.com 2019 - 2024. All rights reserved.