PlatformIO Community

Redirecting the iostream

My goal is to redirect the stdio and iostream to my UART.

My main.cpp is pretty simple:

#include <uart.h>
#include <iostream>

int main() {

    while (true) {
        std::cout << "test" << std::endl;
        for (int i = 0; i < 180000; ++i);

I would expect to have to include something like:

#include <stdio.h>

int fputc(int ch, FILE *f)
    return ch;

But the project builds without it and not surprisingly doesn’t output anything as it doesn’t know which IO to use.

My platformio.ini:

platform = ststm32
board = disco_f407vg
framework = cmsis
upload_protocol = jlink
debug_tool = jlink
build_flags = -O0 --specs=nano.specs
build_type = debug

I thought for GCC you’d have to implement _write()? Have you tried