modm API documentation
Standalone printf/sprintf formatted printing function library

lbuild module: modm:printf

This is a small but fully-loaded implementation of C's formatted printing family of functions. It was originally designed by Marco Paland, with the primary use case being in embedded systems - where these functions are unavailable, or when one needs to avoid the memory footprint of linking against a full-fledged libc. The library can be made even smaller by partially excluding some of the supported format specifiers during compilation. The library stands alone, with no external dependencies**.

For the library API see


On embedded targets, the printf family of functions are automatically replaced by this module using the -fno-builtin-printf compile flag to prevent compiler optimizations to substitute simple calls with puts. 64-bit integer support is disabled by default on AVRs. You can overwrite these defaults in a modm_config_printf.h file placed into your top-level include path:

// 64-bit long long support is disabled on AVR by default
// 5 instead of 6 for backwards compatibility
// Only on embedded targets, on hosted the libc implementation is used

Redirecting the Output

All output is directed to a single function, which you must overwrite in your application to the interface of your choice.

extern "C" void putchar_(char c)
// Redirect the printf output to UART.
// or IOStream if the board already has a logger
// MODM_LOG_INFO << c;