This mini‑series lays out practical conventions adopted after moving a maintained project to C23. First, strict return-value checking with nodiscard prevented real bugs but created situations where results are intentionally ignored; the custom UNUSED() macro was replaced by C23's maybe_unused attribute. The pattern maybe_unused auto _ = foo() is used to silence nodiscard without losing compiler enforcement, and a suggested macro can generate unique unused identifiers when desired.
Second, C23 changes initialization semantics: empty-brace initialization ({}) now reliably zeroes entire unions, fixing cross-compiler surprises where partial initializers or {0} left union members uninitialized; {0} retains its previous behavior, so care is still required and placing the largest union member first is safer. Third, enums previously allowed the compiler to widen the underlying type, which breaks assumptions for bitflags; explicitly specifying the underlying integer (enum options : int { ... }) produces predictable sizes and bitwise behavior. These conventions emphasize safety, predictability, and modern C features, with more patterns promised in the next installment.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.