4 ms·
>surely you would only define the libxo format string once, and then reuse it everywhere I would be rather scared of using a variable for a format string. IMHO
by yyyk 3y ago
>surely you would only define the libxo format string once, and then reuse it everywhere
I would be rather scared of using a variable for a format string. IMHO, these types of format strings are an antipattern for a different reason - we don't see the format at point of use, if we make some too easy mistakes, we have a crash or CVE*. I think nowaways there are tools to do some verification**, and I guess we could use an IDE (but most C programmers don't?), but I am unfamiliar with any such tool which supports libxo style format strings.
* https://en.wikipedia.org/wiki/Format_string_attack https://en.wikipedia.org/wiki/Format_string_attack
** IIRC, GCC/Clang eventually added a verifier? But it doesn't apply to all cases or scanf? I don't recall.