Last active
December 17, 2023 05:44
-
-
Save MartelliEnrico/de3063d9956a85712116 to your computer and use it in GitHub Desktop.
C defer for GCC
This file contains 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
#pragma once | |
#define defer_(x) \ | |
void _dtor_##x(); \ | |
int __attribute__((cleanup(_dtor_##x))) _dtorV_##x; \ | |
void _dtor_##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