Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: How to make printf() to work?

  1. #1

    How to make printf() to work?

    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?

  2. #2
    Senior Member
    Join Date
    Apr 2014
    You might be interested in this thread:

  3. #3
    Thanks @luni, this is what I was looking for.

  4. #4
    Join Date
    Jan 2013
    The link in #2 ties into the way stdio uses _write - another option is, FWIW:

    int printf (const char *fmt ...) {
        va_list ap;
        va_start(ap, fmt);
        auto r = vdprintf((int) &Serial, fmt, ap);
        return r;
    (the _write approach will also take care of puts, putchar, etc - this override won't)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts