[HN Gopher] Type safe variadic printf
___________________________________________________________________
Type safe variadic printf
Author : todsacerdoti
Score : 8 points
Date : 2025-02-14 20:12 UTC (2 hours ago)
(HTM) web link (www.stranger.systems)
(TXT) w3m dump (www.stranger.systems)
| o11c wrote:
| (title omits: in Idris)
|
| But it's really not fair to C to exclude all the special compiler
| support we _do_ have with -Werror=format=2. Given the existence
| of the format /format_arg attributes it's really quite powerful;
| the only thing that's missing is support for custom formats,
| which requires a compiler plugin.
|
| In C++ you can even make a wrapper macro that safely converts
| arbitrary C++ classes into suitable types for C printf. If you
| know all your types ahead of time you can do similar with C11
| _Generic I think.
___________________________________________________________________
(page generated 2025-02-14 23:00 UTC)