Description
Downstream (https://github.com/arm/arm-toolchain), this is a very highly requested feature for a lot of embedded codebases, in order for it to be compatible with previous libraries. In particular, we need the following to compile.
// Note we need std::endl
std::cout << "Hello, World!" << std::endl;
Link to Discourse post: https://discourse.llvm.org/t/rfc-implementation-of-stdio-on-baremetal/86944
The implementation of this will involve:
- fprintf ([libc] Add putc, fputc, and fprintf to stdio/baremetal #144567)
- vfprintf (easily implementable after fprintf)
- ungetc (requires full
FILE
API) - getc (requires full
FILE
API) - fwrite (requires full
FILE
API) - fflush (requires full
FILE
API + buffering)
It should follow the philosophy of "don't pay for what you're not using". Ideally, this should be written in a way that allows non-semihosted platforms to throw away code.
However, these functions still face the challenges:
fflush
requires buffering, which is difficult (stated at the last Embedded WG meeting)FILE
will need to be defined somewhere.stdout/stderr
need to be defined somewhere. Probably in the semihosting library.
As more of the library gets designed, this will be filled in over time. However, at this moment in time, this still requires discussion. See the Discourse post for more details.