aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md33
1 files changed, 22 insertions, 11 deletions
diff --git a/README.md b/README.md
index bd4c73f..7f91d8d 100644
--- a/README.md
+++ b/README.md
@@ -9,11 +9,11 @@
This is a tiny but **fully loaded** printf, sprintf and snprintf implementation.
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.
+Using the standard libc printf may pull **a lot** of unwanted library stuff and can bloat code size about 20k or is not 100% thread safe. In this cases the following implementation can be used.
+Absolutely **NO dependencies** are required, *printf.c* brings all necessary routines, even its own fast `ftoa`, `ntoa` conversion.
-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.
+If memory footprint is really a critical issue, floating point and 'long long' support and can be turned off via the `PRINTF_FLOAT_SUPPORT` and `PRINTF_LONG_LONG_SUPPORT` compiler switches.
+When using printf (instead of sprintf) you have to provide your own `_putchar()` low level function as console/serial output.
## Highligths and design goals
@@ -28,18 +28,28 @@ Therefore I decided to write an own implementation which meets the following ite
- Support of dec/float number representation (with an own fast itoa/ftoa)
- Reentrant and thread-safe, malloc free
- LINT and compiler L4 warning free, coverity clean, automotive ready
- - Extensive test suite (> 270 test cases) passing
+ - Extensive test suite (> 280 test cases) passing
+ - Simply the best *printf* around the net
- MIT license
## Usage
-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, ...);`
+Add/link *printf.c* to your project and include *printf.h*. That's it.
+Implement your low level output function needed for `printf()`:
+```C
+void _putchar(char character)
+{
+ // send char to console etc.
+}
+```
+
+Usage is 1:1 like the according stdio.h library version:
+```C
+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.**
`sprintf` has no buffer limitation, so when necessary - use it with care!
@@ -115,6 +125,7 @@ The length sub-specifier modifies the length of the data type.
| NTOA_BUFFER_SIZE | 32 | ntoa (integer) conversion buffer size. This must be big enough to hold one converted numeric number, normally 32 is a sufficient value. |
| FTOA_BUFFER_SIZE | 32 | ftoa (float) conversion buffer size. This must be big enough to hold one converted float number, normally 32 is a sufficient value. |
| PRINTF_FLOAT_SUPPORT | defined | Define this to enable floating point (%f) support |
+| PRINTF_LONG_LONG_SUPPORT | defined | Define this to enable long long (%ll) support |
## Test suite