Hacker News new | ask | show | jobs
by AlbertoGP 1285 days ago
I made a small pre-processor that implements block-scoped defer in C, by transforming the source to add the deferred code at each exit point in a function. It is called Cedro: https://sentido-labs.com/en/library/cedro/202106171400/#defe...

That link goes directly to the relevant section in the manual.

It includes a cc wrapper called `cedrocc` so you don’t need intermediate files, and it works hard to produce clean code for the generated parts. The rest is not modified at all. The goal is to be useful even if you only use it once to generate that repetitive code.

The pre-processor `cedro` depends only on the C standard library, and `cedrocc` depends on POSIX.