From 569de268ca835dcb3ed816e797956bba975cb5b8 Mon Sep 17 00:00:00 2001 From: Marco Paland Date: Fri, 13 Oct 2017 13:55:46 +0200 Subject: Updated readme --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6979b9e..8ec250f 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,41 @@ # printf / sprintf for embedded systems This is a tiny but fully loaded printf, sprintf and snprintf implementation. -Primary designed for usage in embedded systems, where printf is not available due to memory issues or in avoidance of linking against libc. -Using the standard libc printf may pull a lot of unwanted library stuff. In this case the following implementation can be used. +Primarily designed for usage in embedded systems, where printf is not available due to memory issues or in avoidance of linking against libc. +Using the standard libc printf may pull a lot of unwanted library stuff and can bloat code size about 20k. In this case the following implementation can be used. Absolutely **NO dependencies** are required, printf.cpp brings all necessary routines, even its own fast ftoa conversion. -If memory footprint is really an issue the floating point support can be turned off via the `PRINTF_FLOAT_SUPPORT` compiler switch. - +If memory footprint is really a critical issue, floating point support can be turned off via the `PRINTF_FLOAT_SUPPORT` compiler switch. When using printf (instead of sprintf) you have to provide your own `_putchar()` low level function as console output. + ## Design goals +There is a boatload of so called 'tiny' printf implementations around. So why this one? +I tested many implementations, but most of them have very limited flag/specifier support, a lot of other dependencies or are just not standard compliant and failing the test suite. +Therefore I decided to write an own implementation which meets the following items: + + - Very small implementation (< 500 code lines) - NO dependencies, no libs, just one module file - - Support of all flags, width and precision sub-specifiers + - Support of all important flags, width and precision sub-specifiers (see below) + - Support of float number representation (with an own fast ftoa) - Reentrant and thread-safe, malloc free - LINT and compiler L4 warning free, clean code - - Extensive passing test suite + - Extensive test suite passing - MIT license ## Usage -This is 1:1 like the according stdio.h library version: + +Add/link `printf.cpp` to your project and include `printf.h`. That's it. +Usage is 1:1 like the according stdio.h library version: `int printf(const char* format, ...);` `int sprintf(char* buffer, const char* format, ...);` `int snprintf(char* buffer, size_t count, const char* format, ...);` +**Due to genaral security reasons it is highly recommended to use snprintf (with the max buffer size as `count` parameter) only.** + ## Format specifiers -- cgit v1.2.3