As far as the formatting part is concerned, if you just want to look at an implementation, FreeBSD's is extremely nice and readable:<p><a href="https://github.com/lattera/freebsd/blob/master/lib/libc/stdio/vfprintf.c" rel="nofollow">https://github.com/lattera/freebsd/blob/master/lib/libc/stdi...</a><p>For FRRouting, we decided we want to use Linux kernel style extensions (like "%pI4"), so to get this in a portable way we imported FreeBSD's printf into our code. Since printf() isn't exactly "hot" code getting changed a lot, we considered the maintenance / duplication cost acceptable.<p>You can see the result here:<p><a href="https://github.com/FRRouting/frr/tree/master/lib/printf" rel="nofollow">https://github.com/FRRouting/frr/tree/master/lib/printf</a><p><a href="http://docs.frrouting.org/projects/dev-guide/en/latest/logging.html" rel="nofollow">http://docs.frrouting.org/projects/dev-guide/en/latest/loggi...</a><p>stdio support is completely gone in our copy, WCHAR_SUPPORT is disabled at compile time, locale support is stubbed out/hardcoded to C locale. None of these matter to us. As a result, we can use this printf even in the SEGV handler. (That's only a bonus though, the main reason was extensibility on the format specifiers.)