The output for this code printed out ‘Success’.
printf("%m\n");
The output for this code printed out ‘Success’.
printf("%m\n");
On
Actually, the manual of printf() concerning %m is quite laconic:
m (Glibc extension; supported by uClibc and musl.) Print output
of strerror(errno). No argument is required.
But strerror() is not multi-thread safe: it is not reentrant. The thread-safe version is strerror_r().
A little study of the GLIBC implementation shows that %m is actually equivalent to strerror_r() and not to strerror(). Hence %m is thread-safe! The online manual is consequently wrong (or at least not accurate enough)!
mconversion specifier is not C but is a GNU extension toprintf:From GNU documentation:
http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html
So:
is equivalent to
which is equivalent to
Note that
%mdoes not require an argument. Hereprintf("%m\n", d)andprintf("%s\n", strerror (errno), d)have more arguments than required: withprintfif there are extra trailing arguments, they are just evaluated and ignored.