Eight different approaches to implementing defer functionality in C are explored, ranging from compiler-specific solutions using GCC's cleanup attribute and nested functions to portable implementations using setjmp/longjmp or manual defer stacks. The C23/GCC version uses nested functions with cleanup attributes, while a

9m read timeFrom antonz.org
Post cover image
Table of contents
C23/GCCC11/GCCGCC/ClangMSVCLong jumpSTCStackSimplified GCC/ClangFinal thoughts

Sort: