Only applicable when using setting (NEWLIB=NOSTD) in makefile. Toggle between the Lite and Full printf implementations and enable specific format specifiers.
Printf Module Selection | |
Printf Wrapper Helper, ignore it. Toggle between the Lite and Full printf implementations. | |
| #define | ENABLE_BSP_PRINTF 1 |
| (Lite) Supports char, string, decimal, hex, floats. Moderate memory footprint. | |
| #define | ENABLE_BSP_PRINTF_FULL 1 |
| (Full) Full support including flags and precisions. Larger memory footprint. | |
| #define | ENABLE_BRIDGE_FULL_TO_LITE 1 |
| Enable function sharing between 'full' and 'lite' printing modules. | |
| #define | ENABLE_PRINTF_WARNING 1 |
| Print a warning message when a format specifier is not supported. | |
Extended Format Specifier Support | |
Enable specific data types (Costs extra memory). | |
| #define | ENABLE_FLOATING_POINT_SUPPORT 0 |
| Support for f (Printing only). | |
| #define | ENABLE_FP_EXPONENTIAL_SUPPORT 0 |
| Support for e / E. | |
| #define | ENABLE_PTRDIFF_SUPPORT 0 |
| Support for t (Pointer differences). | |
| #define | ENABLE_LONG_LONG_SUPPORT 1 |
| Support for lld / llu. | |
Following are the available printf function when Non-standard library (NEWLIB=NOSTD) is in used.
bsp_printf is a lightweight alternative to the standard C library printf. It supports a minimal set of format specifiers to significantly reduce the compiled binary size. bsp_printf is automatically enabled when the project is compiled with NEWLIB = NOSTD.
It supports the following standard format specifiers:
Single-Format Print Functions (Ultra-lightweight Printf)
For even stricter control over user's code footprint, the BSP provides ultra-lightweight functions that only handle one specific format type at a time:
Bsp_printf_full is based on open-source Tiny Printf implementation. This printf function supports most of the specifiers. Bsp_print_full is disabled by default. Bsp_printf_full can be enabled by setting the ENABLE_BSP_PRINTF_FULL to 1 in the bsp.h file.
The bsp_printf_full follows the following prototype: %[flags][width][.precision][length]type
Supported Format Types:
| Type | Description |
|---|---|
| d or i | Signed decimal integer |
| u | Unsigned decimal integer |
| b | Unsigned binary |
| o | Unsigned octal |
| x | Unsigned hexadecimal integer (lowercase) |
| X | Unsigned hexadecimal integer (uppercase) |
| f or F | Decimal floating point |
| e or E | Scientific-notation (exponential) floating point |
| g or G | Scientific or decimal floating point |
| c | Single character |
| s | String of characters |
| p | Pointer address |
| %% | Outputs a literal % character |
| #define ENABLE_BRIDGE_FULL_TO_LITE 1 |
| #define ENABLE_BSP_PRINTF 1 |
| #define ENABLE_BSP_PRINTF_FULL 1 |
| #define ENABLE_FLOATING_POINT_SUPPORT 0 |
| #define ENABLE_FP_EXPONENTIAL_SUPPORT 0 |
| #define ENABLE_LONG_LONG_SUPPORT 1 |
| #define ENABLE_PRINTF_WARNING 1 |