|
solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
|
Cross-platform defer statement implementation for automatic resource cleanup. This header provides a 'defer' statement that executes code when the current scope exits, similar to Go's defer or other languages' scope guards. More...
#include <stddef.h>Go to the source code of this file.
Cross-platform defer statement implementation for automatic resource cleanup. This header provides a 'defer' statement that executes code when the current scope exits, similar to Go's defer or other languages' scope guards.
References:
C++: g++ main.cpp clang++ main.cpp cl main.cpp (MSVC) No special flags required - uses RAII with lambdas
C with GCC: gcc -fno-trampolines main.c Uses function descriptors (safe, no executable stack required)
Alternative for GCC 4.9+: gcc main.c Uses nested functions with auto storage class (safe, no trampolines)
C with Clang: clang -fblocks -lBlocksRuntime main.c Requires blocks runtime library
Install blocks runtime: Ubuntu/Debian: sudo apt-get install libblocksruntime-dev Arch Linux: sudo pacman -S libdispatch
C with MSVC: cl main.c Uses __try/__finally (no special flags required)
Definition in file defer.h.