[Bug c/47781] warnings from custom printf format specifiers
tromey at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 14 14:10:01 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781
--- Comment #24 from Tom Tromey <tromey at gcc dot gnu.org> ---
(In reply to David Crocker from comment #23)
> I need this feature too. Instead of waiting several more years for an
> all-singing all-dancing solution, PLEASE can we have a simple solution that
> allows me to use a custom format specifier and skips a single argument for
> that specifier. I believe this would cover the vast majority of uses custom
> format specifiers. My particular use case is that my application generates a
> lot of JSON strings, so in my printf replacement I want to implement a
> specifier similar to %s that performs JSON escaping on characters in the
> string.
As a workaround, see the kernel doc linked earlier in this bug.
gdb uses this hack as well -- e.g., it uses "%ps" in its formatter
to mean a styled string, passed as a pointer to get past gcc's checking.
More information about the Gcc-bugs
mailing list