Tech News
← Home  ·  All topics

Ideal Gas Law

1 GoKawiil brief on this topic · RSS for ideal gas law

C technique uses designated initializers to simulate named, default function arguments

A blog post revisits a pattern from Ben Klemens' 2014 book 21st Century C that uses C's designated initializers, combined with a struct and macro, to let function calls take optional, named arguments with default values. The technique relies on two C-specific behaviors not adopted by C++20: initializers can appear in any order, and repeated designators simply overwrite earlier ones, with the last value taking effect.