Re:Modern C for C++ Peeps
by gomijacogeo on Sunday January 08, 2023 @05:34AM
(#34297873)
stdint.h includes definitions for format strings for printf/scanf-type functions (e.g. PRId64, ...) for all the new types. Using them is a bit clunky (e.g. printf("%"PRId64"\n",n);), but you get used to it.
[ Parent
| on HN ]
Re:Modern C for C++ Peeps
by WalterBright on Sunday January 08, 2023 @03:40PM
(#34302863)
True, but "a bit clunky" is an understatement for how awful they look. I've never seen them used in the wild. I don't use them either.
What I do use (since D supports calling C printf) is have the compiler check the format string against the types of the arguments. This means it won't compile if there's a mismatch. Many C compilers do this, too.