News for hackers. Stuff that matters.
Re:Type-Safe Printf for C by jhallenworld on Tuesday December 14, 2021 @02:53PM (#29556606)
So I also have a custom printf, but there is a limitation: if you ask gcc to check it with "__attribute__((__format__ (__printf__", then you are forced into using gcc's idea of what the printf format string syntax.

How can I have strict type checking, but a user defined format string?

Re:Type-Safe Printf for C by wahern on Tuesday December 14, 2021 @09:06PM (#29561162)
The format attribute takes the argument positions of the format string and the first variadic argument. You can pass the types as a separate array (compound literal array) as any argument before the beginning of the variadic portion, just as you would if passing in the number of variadic arguments (which one should also do to ensure the number of format specifiers matches the number of passed arguments). The magic for detecting types (e.g. _Generic) would all be the same, but there'd be a little more duplication for the variable argument macro magic. I've implemented this both ways and I don't recall there being any significant difference, but it's been awhile.
Re:Type-Safe Printf for C by kevin_thibedeau on Tuesday December 14, 2021 @03:18PM (#29556963)
Write your own linter.