How to make printf() to work?

zapta

Well-known member
I am using Teensy 4.1 with platformio and the configuration below.

platform = teensy
board = teensy41
framework = arduino

Serial.printf() does work and prints to the serial-over-USB but printf() does not and hangs the program.

Is there a way to have printf working in the same way that Serial.printf() works?
 
The link in #2 ties into the way stdio uses _write - another option is, FWIW:

Code:
int printf (const char *fmt ...) {
    va_list ap;
    va_start(ap, fmt);
    auto r = vdprintf((int) &Serial, fmt, ap);
    va_end(ap);
    return r;
}

(the _write approach will also take care of puts, putchar, etc - this override won't)
 
Back
Top