The %m format specifier is a documented feature of syslog, but gcc gives a
warning when -Wpedantic is used. Is this a bug?

For example, the program:

#include <syslog.h>
int main(void)
{
    syslog(LOG_ERR, "%m");
    return 0;
}

gives:
warning: ISO C does not support the ‘%m’ gnu_printf format [-Wformat=]

when compiled[1] with
gcc -Wall -Wextra -Wpedantic -o test test.c

The man page for syslog(3) states that %m is supported: "the two-character
sequence %m will be replaced by the error message string strerror(errno)."

Submitting a bug report for this feels like arguing that the answer in the
back of the book is wrong (...rarely the right move). What am I missing
here?

Thanks in advance,

  Kris

[1]: gcc (GCC) 11.2.1 20211203 on Linux version 5.15.16-200.fc35.x86_64
(Fedora v35)

Reply via email to