Skip to content

Instantly share code, notes, and snippets.

@Bunn
Created May 1, 2020 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bunn/ad4c1238936c9a30659a9310cb0a23b5 to your computer and use it in GitHub Desktop.
Save Bunn/ad4c1238936c9a30659a9310cb0a23b5 to your computer and use it in GitHub Desktop.
static inline void func_to_cleanup(void (^*block)(void)) {
(*block)();
}
#define concat(a,b) a##b
#define defer(deferBlock) __attribute__((cleanup(func_to_cleanup))) void (^__unused concat(defer_tmp_var, __COUNTER__))(void) = deferBlock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment