Defer has landed in Clang and will (probably, most likely) land for Clang 22! Should show up in Godbolt within the next 48 hours or so, too:
https://github.com/llvm/llvm-project/commit/71bfdd13040328bc83b520d09eee847fd2b7f82c
@Girgias set-reminder-5-years: add _Defer E V E R Y W H E R E
@thephd C programming hobbyists(noob) here. Defer in other languages seems to have a couple uses but what's jumping to my mind for C is putting my memory allocation and freeing of that memory next to each other so it's easier to keep track?
Also is Godbolt another name for Compiler Explorer?
@CyberB @thephd defer is mostly here to give peace of mind of "i won't forget to clean up this thing", much like in other languages, and ensures you don't need to handle it in every case, which, in case of error, could lead to errors like use after free, or double free
and yes godbolt is another name for compiler explorer
@thephd why every single new syntax change in the latest C standards feels wrong. I wish we could just see better good practices and simplicity enforced to avoid mistakes, not more ways to introduce bugs hard to spot