xprintf d727b10
Xprintf documentation

Documentation for the xprintf project at github

github_logo.png
Version:
git://github.com/robbesol/xprintf commit d727b10e8cffbe82fdb108312de5fdbf40eeec48

Overview

ISO C99 fprintf() formatting implementation aimed at embedded SW. Your output stream is easily connected. Small code and stack footprint, no malloc(). Full ISO C99 implementation, floating point support can be disabled.

History

Xprintf is an independent implementation of the printf() formatting facility. It is written from the ground up by Markus van Dijk, while employed by Technologies88.

Note:
No code was borrowed from any commercial and/or open source.

The xprintf code was used for several years for all string formatting in an embedded project, including debug output to a PC, writing to an embedded display and writing to files.
In august 2011 Technologies88 kindly gave permission to enter the code into the public domain and transferred all rights to Markus van Dijk.
The code now lives as xprintf project at github.

Compliance

This implementation of printf formatting claims to be compliant with the ISO C99 standard with corrigenda TC1, TC2, and TC3 included.

Note:
Common GNU extensions like positional parameters "%1$d" are not supported.
See also:
open-std.org -> C standards -> C99 (PDF).
UNIX: man 3 printf

Flags

All flags are implemented: [#0- +].

Minimum field width

The minimum field width is implemented, including the '*' specifier.

Precision

The precision is implemented, including the '*' specifier.

Integral conversion

Conversion specifiers %d %i %o %u %x %X with length modifiers hh h l ll j z t are fully implemented.

Double conversion

Conversion specifiers %f %F %e %E %g %G with optional length modifier l are fully implemented, but no inf/nan output.
Length modifier L (long double) is supported, but only produces the accuracy of a double.
Conversion specifiers %a %A are not implemented.

String conversion

Conversion specifiers %c %s without length modifiers are fully implemented.
Wide characters (length modifier l for types wint_t and wchar_t) are not implemented.
Conversion specifier %#s: an extra # flag is implemented that will print the string "visually", using "\n", "\r", "\t" and "\ooo" (octal) for non-printable chars and "\\" for '\'.

Pointer conversion

Conversion specifier %p is implementation dependent and formatted as %#x

Write length to argument conversion

Conversion specifier %n without length modifiers (argument type int*) is fully implemented.
Conversion specifier %n with length modifiers (argument type other than int*) is not implemented.

Percent conversion

Conversion specifier %% is fully implemented :-)

Other

NOTE: these functions have to be reentrant, so:

[Wikipedia]
A computer program or routine is described as reentrant if it can be safely executed concurrently; that is, the routine can be re-entered while it is already running.
To be reentrant, a function
  • must hold no static non-constant data,
  • must not return the address to static non-constant data,
  • must work only on the data provided to it by the caller,
  • must not rely on locks to singleton resources, and
  • must not call non-reentrant functions.