Would you believe try-catch-finally works in plain old C?

4 points by mf_taria 9 hours ago

I was digging through some of my old repositories and found a C language extension I wrote years ago. Even now, I think it’s kinda cool — and I’d love for you to check it out.

https://github.com/simpart/c-try

It recreates `try {}` / `catch {}` / `finally {}` in plain C using just macros and global variables. There's also a `$` macro to propagate errors between function calls — a bit like a mini DSL for error handling.

You can find a working example in `test.c`.

It doesn't support nesting or multithreading, and yes, it abuses macros. But hey, it's C.