Created
March 20, 2017 15:43
-
-
Save phausler/affdf697165cfb36dd15c1ec95a2e4ad to your computer and use it in GitHub Desktop.
Defer for c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__attribute__((used)) | |
static inline void __deferred(void (^*b)(void)) { if (b) (*b)(); } | |
#define ___PASTE__(x, y) x ## y | |
#define __PASTE__(x, y) ___PASTE__(x, y) | |
#define defer(block) void (^__PASTE__(__cleanup, __COUNTER__))(void) __attribute__((cleanup(__deferred), unused)) = block |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment