aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2017-11-13 09:29:14 +0100
committerMarco Paland <marco@paland.com>2017-11-13 09:29:14 +0100
commit7936fc34c4e2f734981832c1201777cb429d4a0a (patch)
tree4014fe08ad61119b5764286ec343bea9467105b1
parent65b9a297d3433fc8b2d6ca65c430b835b25923d0 (diff)
downloadprintf-7936fc34c4e2f734981832c1201777cb429d4a0a.tar.gz
printf-7936fc34c4e2f734981832c1201777cb429d4a0a.tar.bz2
printf-7936fc34c4e2f734981832c1201777cb429d4a0a.zip
Changed printf.cpp to printf.c to be usable with 'C'-compilers
closes #1
-rw-r--r--README.md18
-rw-r--r--printf.c (renamed from printf.cpp)0
-rw-r--r--test/test_suite.cpp8
3 files changed, 17 insertions, 9 deletions
diff --git a/README.md b/README.md
index bd4c73f..7af4a2f 100644
--- a/README.md
+++ b/README.md
@@ -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:
-
+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!
diff --git a/printf.cpp b/printf.c
index 3e466b2..3e466b2 100644
--- a/printf.cpp
+++ b/printf.c
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index a291cc7..9e186aa 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -35,15 +35,13 @@
namespace test {
// use functions in own test namespace to avoid stdio conflicts
#include "../printf.h"
- #include "../printf.cpp"
+ #include "../printf.c"
} // namespace test
// dummy putchar
-int test::_putchar(char)
-{
- return 0;
-}
+void test::_putchar(char)
+{ }