tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Adding %m conversion to the printf(3) family

In article <>,
Joerg Sonnenberger  <> wrote:
>On Fri, Oct 23, 2015 at 10:33:52PM +0100, Roy Marples wrote:
>> Instead of trying to make gcc work better, I propose that our libc printf(3) 
>> family of functions instead support %m.
>This has been discussed before and I don't believe you have given any
>new convincing arguments.
>> this proposal, I expect you to supply a working solution to the problem noted 
>> at the top of this email. A valid solution could be reverting the gcc change 
>> and keeping the status quo.
>It would help if you give a test case of what problem you are actually
>talking about. I still have no clue what you reall mean.

#include <stdio.h>
#include <stdarg.h>

static void __attribute__((__format__(__syslog__, 2, 3)))
logmein(int fd, const char *fmt, ...)
	va_list ap;
	va_start(ap, fmt);
	vdprintf(fd, fmt, ap);

main(void) {
	logmein(1, "%s %m\n", "foo");
	return 0;

$ gcc -Wformat=2 -Wmissing-format-attribute logfmt.c
logfmt.c: In function 'logmein':
logfmt.c:9:2: warning: function might be possible candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
 vdprintf(fd, fmt, ap);

Home | Main Index | Thread Index | Old Index