People would answer officialy like: conversions with capital letters like %C and %S (not %c and %s) print things in parsable formats by OCaml. The change of %b to %B followed this, since it prints booleans as true and false which are also OCaml parsable.

You can find a backstory here: http://caml.inria.fr/mantis/view.php?id=1438 . There was a branch which introduced this %B then changed the meaning of %b for binaries. The latter broke the backward compatibility therefore that part was rejected. As the result, today we have two conversions for booleans %B and %b.

Answer from camlspotter on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/bash โ€บ potential incompatible change to printf's '%b' format specifier
r/bash on Reddit: Potential incompatible change to printf's '%b' format specifier
September 2, 2023 -

The people coming up with the next C language standard are proposing new printf() format specifiers %b and %B, to output integers as binary literals, i.e. 0b00010110, the binary representation of 22.

The section of the Bash manual describing the builtin printf command references the manual for the external printf program, printf(1); which itself references the manual for the C function printf(), printf(3). The Bash builtin printf command supports a bunch of C-language printf() format specifiers, so they just direct you to that documentation to see how those work.

However, the Bash builtin printf supports additional format specifiers, beyond those supported by the C-language printf(). One of those is %b, which in the case of Bash's printf, currently "causes printf to expand backslash escape sequences in the corresponding argument in the same way as echo -e."

A number of people from the Austin Group, the people behind the POSIX specification, emailed in to the bug-bash email list, where Bash development discussion takes place, saying that they would like a new POSIX standard to change the mandated behavior of the %b format specifier used by the command-line printf command, whether that's an external program or the Bash builtin, to mirror the behavior of this format specifier as used by the C printf() function in the upcoming C standard. They are recommending %#s, signifying an alternative string format, to take over the duties of the current %b. They do seem to be saying that they'd only change the standard in this way if they get buy-in from shell authors, though.

Chet Ramey, the Bash maintainer, really wasn't having it:

I don't have a problem adding %#s. I have a problem with POSIX not seeing that the printf builtin is not a direct parallel to the library function and forcing an incompatible change.

So, do scripts you write or maintain use the %b printf format specifier? What's your take on all this?

๐ŸŒ
Arch Linux Forums
bbs.archlinux.org โ€บ viewtopic.php
dash printf and format string "%b" in particular / Programming & Scripting / Arch Linux Forums
July 10, 2015 - You cannot specify any options after %b. %b is the same as %s, except that escape sequences in the string are interpreted. $ printf "%s\n" 'foo\nbar \0101' foo\nbar \0101 $ $ printf "%b\n" 'foo\nbar \0101' foo bar A $
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ function.printf.php
PHP: printf - Manual
As of PHP 8.0.0, a ValueError is thrown if [precision] is less than zero or bigger than PHP_INT_MAX. Prior to PHP 8.0.0, a E_WARNING was emitted instead. As of PHP 8.0.0, a ArgumentCountError is thrown when less arguments are given than required. Prior to PHP 8.0.0, false was returned and a E_WARNING emitted instead. ... <?php $n = 43951789; $u = -43951789; $c = 65; // ASCII 65 is 'A' // notice the double %%, this prints a literal '%' character printf("%%b = '%b'\n", $n); // binary representation printf("%%c = '%c'\n", $c); // print the ascii character, same as chr() function printf("%%d = '%d
๐ŸŒ
NV5 Geospatial Software
nv5geospatialsoftware.com โ€บ docs โ€บ Format_Codes_CPrintf.html
C printf-Style Format Codes
View our Documentation Center document now and explore other helpful examples for using IDL, ENVI and other products.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ printf-command-in-linux-with-examples
printf command in Linux with Examples - GeeksforGeeks
January 22, 2025 - The %b format specifier is an enhanced version of %s. It not only prints the string but also processes any escape sequences embedded in the string, interpreting them as commands. Input: printf "%s\n" "Hello, World!
๐ŸŒ
The Open Group
pubs.opengroup.org โ€บ onlinepubs โ€บ 9799919799 โ€บ utilities โ€บ printf.html
printf
Note that this printf utility, like the printf() function defined in the System Interfaces volume of POSIX.1-2024 on which it is based, makes no special provision for dealing with multi-byte characters when using the %c conversion specification or when a precision is specified in a %b or %s conversion specification.
Top answer
1 of 2
2

The reason for the discrepancy in your results is that the Raspberry Pi C SDK uses a different C library than the one on your Ubuntu system. Specifically, the picolibc library is used by the SDK for code compiled for a Pico target system. This would explain why you get no errors or warnings when the target is a Pico.

OTOH, glibc is the C library used for compilations targeted for Ubuntu. This is a bit of a guess, but I can imagine that since the first version of glibc to support the %b format was 2.35 (the version on your Ubuntu system), there was some unsettled business between gcc and glibc that resulted in a warning. I say this because earlier versions of glibc (e.g. ver 2.31) and gcc (ver 10.2.1) produced an error instead of a warning upon seeing the %b conversion in printf, and compile without error or warning w/ glibc ver 2.36 and gcc ver 12.2.

2 of 2
1

The Raspberry toolkit uses a different C compiler and C library, and seems to support the %b format at runtime (binary output) and compiler time (no warning).

Conversely, on the Ubuntu host, your C library supports the %b format (including the # option) as shown on the output, but the C compiler does not and reports a compile time warning.

The gcc warnings for printf and scanf argument consistency are produced at compile time by the compiler built-in analyser. The compiler does not use the C library for this so it may report a problem where the C library does support an extended format.

This inconsistency should be fixed with a more recent version of gcc, so you should either upgrade your system or install a more recent version of gcc manually. You can also check the behavior of clang.

You can disable these warnings, but they are very useful to avoid stupid mistakes, so you should do this on a case by case basis with pragmas.

Find elsewhere
๐ŸŒ
Thinkage
thinkage.ca โ€บ gcos โ€บ expl โ€บ b โ€บ lib โ€บ printf.html
PRINTF - formatted print.
This is the same as "%b", except that BCD letters are translated into upper case ASCII. ... The argument is printed as one to four ASCII characters, right-justified. '*e' characters occurring in the argument are not printed. Thus if the argument is 'ab*ec' and the format "%c", PRINTF prints "abc".
๐ŸŒ
Nagios
support.nagios.com โ€บ board index โ€บ community support forums for nagios open source projects โ€บ open source nagios projects
printf "%b" in notification command definition - Nagios Support Forum
%b ARGUMENT as a string with '\' escapes interpreted, except that octal escapes are of the form \0 or \0NNN One could argue that this is so you can pass in arbitrary "blobs" (hence, "b") of data that don't get interpreted as further \-codes. So, basically, you're half right. This is so the macros that Nagios passes in, which may have weird stuff in them, get printed out properly instead of interpreted by the printf itself.
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ bash printf syntax examples
Bash printf Command: Syntax & Examples for Linux
September 21, 2025 - As you could seen in the previous simple examples, we have used %s as a format specifier. The most commonly used printf specifiers are %s, %b, %d, %x and %f. The specifiers are replaced by a corresponding argument.
๐ŸŒ
GNU
gnu.org โ€บ software โ€บ coreutils โ€บ printf
printf invocation (GNU Coreutils 9.11)
Missing arguments are treated as null strings or as zeros, depending on whether the context expects a string or a number. For example, the command โ€˜printf %sx%dโ€™ prints โ€˜x0โ€™. Indexed arguments referenced with โ€˜%...$โ€™ formats, can be mixed with standard sequential argument references, ...
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Printf_(Unix)
printf (Unix) - Wikipedia
May 10, 2026 - printf is a shell command that formats and outputs text like the same-named C function. It is available in a variety of Unix and Unix-like systems. Some shells implement the command as builtin and some provide it as a utility program
๐ŸŒ
Linux Man Pages
man7.org โ€บ linux โ€บ man-pages โ€บ man1 โ€บ printf.1.html
printf(1) - Linux manual page
May 24, 2026 - Print ARGUMENT(s) according to FORMAT, or execute according to OPTION: --help display this help and exit --version output version information and exit FORMAT controls the output as in C printf. Interpreted sequences are: \" double quote \\ backslash \a alert (BEL) \b backspace \c produce no ...
๐ŸŒ
Cplusplus
cplusplus.com โ€บ reference โ€บ cstdio โ€บ printf
Printf
int printf ( const char * format, ... ); Print formatted data to stdout ยท Writes the C string pointed by format to the standard output (stdout).
๐ŸŒ
OCaml
ocaml.org โ€บ api โ€บ Printf.html
OCaml library : Printf
The integer in a width or precision ... For instance, %.*f prints a float with as many fractional digits as the value of the argument given before the float. ... Same as Printf.fprintf, but output on stdout....
๐ŸŒ
L3harrisgeospatial
l3harrisgeospatial.com โ€บ docs โ€บ format_codes_cprintf.html
C printf-Style Format Codes - NV5 Geospatial
August 14, 1998 - View our Documentation Center document now and explore other helpful examples for using IDL, ENVI and other products.
๐ŸŒ
SS64
ss64.com โ€บ bash โ€บ printf.html
printf Man Page - Linux
The format characters and their meanings are: \" double quote \0NNN character with octal value NNN (0 to 3 digits) \\ backslash \a alert (BEL) \b backspace \c produce no further output \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \xNNN byte with hexadecimal value NNN (1 to 3 digits) \uNNNN character with hexadecimal value NNNN (4 digits) \UNNNNNNNN character with hexadecimal value NNNNNNNN (8 digits) %% a single % %b ARGUMENT as a string with '\' escapes interpreted %Wd Integer 'W' digits wide xxxx %W.De Scientific notation x.xxxx e nnn. float, double %W.Df Fix
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Printf_format_string
printf - Wikipedia
May 29, 2026 - The standard library provides other, similar functions that form a family of printf-like functions. The functions share the same formatting capabilities but provide different behavior such as output to a different destination or safety measures that limit exposure to vulnerabilities.