m
conversion specifier is not C but is a GNU extension to printf
:
From GNU documentation:
http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html
The ‘%m’ conversion prints the string corresponding to the error code in errno. See Error Messages. Thus:
fprintf (stderr, "can't open `%s': %m
", filename);
is equivalent to:
fprintf (stderr, "can't open `%s': %s
", filename, strerror (errno));
The ‘%m’ conversion is a GNU C Library extension.
So:
printf("%m
", d);
is equivalent to
printf("%s
", strerror (errno), d);
which is equivalent to
printf("%s
", strerror (errno));
Note that %m
does not require an argument. Here printf("%m
", d)
and printf("%s
", strerror (errno), d)
have more arguments than required: with printf
if there are extra trailing arguments, they are just evaluated and ignored.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…