Skip to content

Commit 268759b

Browse files
author
Amanda Butler
authored
Add content to printf.md
Apply changes from PR #1140 to v5.13.
1 parent de9ade6 commit 268759b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
## printf
1+
# printf and reducing memory
22

3-
[Optimization document about best practices, guidelines and dos and don'ts for printf]
3+
The standard library family of `printf` (`printf`, `sprintf`, `fprintf` and so on) calls takes a lot of code space. This is because there are multiple format specifiers, and it is not possible to optimize the code at build time. Even a single `printf` call in your application pulls in the entire standard library.
4+
5+
A solution to reduce code space is to replace the standard `printf` calls with a smaller implementation.
6+
7+
Mbed OS provides the [`minimal-printf` library](https://github.com/ARMmbed/mbed-os/blob/master/platform/source/minimal-printf/README.md), which offers a subset of the `printf` features (not all format specifiers are supported). You can also achieve further flash savings if your application does not require 64-bit integers, floating point or FILE stream printing by disabling support through the [configuration file](https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_lib.json).
8+
9+
For a memory footprint comparison between standard `printf` and `minimal-printf`, please see our [Blinky size comparison](https://github.com/ARMmbed/mbed-os/tree/master/platform/source/minimal-printf#size-comparison).

0 commit comments

Comments
 (0)