I have a custom implementation of printf which I use in my school projects.
Wishing to have the same warnings that printf, I use __attribute__((format (printf ...))
. That works fine, but using -Wall -Wextra -Werror -std=c11 -pedantic-errors
, I get the error ISO C does not support %n$ operand number formats
on gcc 7.2.0. (My implementation support that format).
On clang it does not shout a warning if I use std=c11
, but does with std=c99
.
Is that format part of the c11 specification (as clang behavior let me think) or only the Singe Unix Specification (that is what my man page says) ? If so, how can I use it ? In this page, I cannot find it as an option to std
.
I would rather not disable any warnings, since they are quite useful and catches a lot. But is there a way to allow that format in format strings, or specify only for my function ?
Thanks a lot.
P.S: I use a custom implemenation of printf because in my school projects we must only use specific allowed functions (basically, system api like malloc
, free
, read
etc), or the one we have done ourselves.
EDIT : for reference, the format %n$
, with n
being string of digit for a non-zero number, allow to access the argument at that index (starting at one) in the list of variable arguments given to printf. (And can be used for the conversion itself or for the precision or field widht with the *
operand).