Created
January 22, 2016 22:27
-
-
Save bvk/88879332aeca41a7482c to your computer and use it in GitHub Desktop.
Go like "defer" for C using GCC extensions
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
#define defer_(x) do{}while(0); \ | |
auto void _dtor1_##x(); \ | |
auto void _dtor2_##x(); \ | |
int __attribute__((cleanup(_dtor2_##x))) _dtorV_##x=69; \ | |
void _dtor2_##x(){if(_dtorV_##x==42)return _dtor1_##x();};_dtorV_##x=42; \ | |
void _dtor1_##x() | |
#define defer__(x) defer_(x) | |
#define defer defer__(__COUNTER__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment