Configuration

This is the default configuration of the middleware. When any of the settings shall be modified, it shall be done in dedicated application config lwprintf_opts.h file.

Note

Check Getting started to create configuration file.

group LWPRINTF_OPT

LwPRINTF options.

Defines

LWPRINTF_CFG_OS

Enables 1 or disables 0 operating system support in the library.

Note

When LWPRINTF_CFG_OS is enabled, user must implement functions in System functions group.

LWPRINTF_CFG_OS_MUTEX_HANDLE

Mutex handle type.

Note

This value must be set in case LWPRINTF_CFG_OS is set to 1. If data type is not known to compiler, include header file with definition before you define handle type

LWPRINTF_CFG_OS_MANUAL_PROTECT

Enables 1 or disables 0 manual mutex lock.

When this feature is enabled, together with LWPRINTF_CFG_OS, behavior is as following:

  • System mutex is kept created during init phase

  • Calls to direct printing functions are not thread-safe by default anymore

  • Calls to sprintf (buffer functions) are kept thread-safe

  • User must manually call lwprintf_protect or lwprintf_protect_ex functions to protect direct printing operation

  • User must manually call lwprintf_unprotect or lwprintf_unprotect_ex functions to exit protected area

Note

If you prefer to completely disable locking mechanism with this library, turn off LWPRINTF_CFG_OS and fully manually handle mutual exclusion for non-reentrant functions

LWPRINTF_CFG_SUPPORT_LONG_LONG

Enables 1 or disables 0 support for long long int type, signed or unsigned.

LWPRINTF_CFG_SUPPORT_TYPE_INT

Enables 1 or disables 0 support for any specifier accepting any kind of integer types. This is enabling d, b, u, o, i, x specifiers.

LWPRINTF_CFG_SUPPORT_TYPE_POINTER

Enables 1 or disables 0 support p pointer print type.

When enabled, architecture must support uintptr_t type, normally available with C11 standard

LWPRINTF_CFG_SUPPORT_TYPE_FLOAT

Enables 1 or disables 0 support f and basic float type.

This feature is a prerequisite feature be enabled for any floating point types (e, E, g, G, a, A, f, F).

Note

Numbers are split into integer and decimal part using native integer math, with no arbitrary-precision (bignum) support, to keep the implementation simple and fast enough for embedded systems. Maximum number of representable integer digits therefore depends on LWPRINTF_CFG_SUPPORT_LONG_LONG: 18 digits when enabled, or 9 when disabled. Once the magnitude of the number exceeds this limit, f/F silently falls back to scientific (e-style) notation instead of printing the full integer part, which is different from standard printf implementations that always keep f in fixed-point notation regardless of magnitude.

LWPRINTF_CFG_SUPPORT_TYPE_ENGINEERING

Enables 1 or disables 0 support for e and g engineering output type for float numbers.

Note

LWPRINTF_CFG_SUPPORT_TYPE_FLOAT has to be enabled to use this feature

LWPRINTF_CFG_SUPPORT_TYPE_STRING

Enables 1 or disables 0 support for s for string output.

LWPRINTF_CFG_SUPPORT_TYPE_BYTE_ARRAY

Enables 1 or disables 0 support for k for hex byte array output.

LWPRINTF_CFG_FLOAT_DEFAULT_PRECISION

Specifies default number of precision for floating number.

Represents number of digits to be used after comma if no precision is set with specifier itself

LWPRINTF_CFG_ENABLE_SHORTNAMES

Enables 1 or disables 0 optional short names for LwPRINTF API functions.

It adds functions for default instance: lwprintf, lwsnprintf and others

LWPRINTF_CFG_ENABLE_STD_NAMES

Enables 1 or disables 0 C standard API names.

Disabled by default not to interfere with compiler implementation. Application may need to remove standard C STDIO library from linkage to be able to properly compile LwPRINTF with this option enabled