I got tired of the usual configuration mess in C—manually writing tedious boilerplate to traverse generic JSON/YAML nodes, casting strings to integers, and writing a dozen if statements to handle out-of-range ports or missing environment variables. Worse yet, managing string lifetimes across nested configuration objects.
To fix this, I built cfgsafe, an Ahead-of-Time (AOT) schema-driven configuration engine for C99. Instead of processing raw files at runtime, it takes a simple schema file and generates a type-safe, single-header library.
I wrote a deep-dive engineering breakdown detailing the philosophy, memory model, and design choices behind it here:
Type-Safe Configs in C99: Why I Prefer Code-Gen over Parsing
And the github repo: CfgSafe
cfg-gen tool outputs a native C struct with matching validation primitives built straight in.Config_load. If a field is invalid or missing, it fails fast before your application's hot path even executes.Config_free().cfg.db.prt instead of cfg.db.port, the compiler refuses to build the app, and your editor knows exactly what fields exist and their data types.secret from auto-generated logs.I would love to hear your thoughts on taking an AOT code-gen approach to application configurations vs. traditional runtime parsers like libconfig or json-c!