aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorMarco Paland <info@paland.com>2017-10-13 13:55:46 +0200
committerMarco Paland <info@paland.com>2017-10-13 13:55:46 +0200
commit569de268ca835dcb3ed816e797956bba975cb5b8 (patch)
tree4a95175c716ef94aa0605b9ed7d6be84a1c5f047 /README.md
parentc250b510ef76fb23ae57f5368a6b2ec20ca95ffe (diff)
downloadprintf-569de268ca835dcb3ed816e797956bba975cb5b8.tar.gz
printf-569de268ca835dcb3ed816e797956bba975cb5b8.tar.bz2
printf-569de268ca835dcb3ed816e797956bba975cb5b8.zip
Updated readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 17 insertions, 7 deletions
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