Created
February 19, 2016 21:18
-
-
Save Mons/5c646d3a4af425465a68 to your computer and use it in GitHub Desktop.
C DEFER
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
// (c) Roman Tokarev | |
#ifndef _DEFER_H_ | |
#define _DEFER_H_ | |
#define CONCAT(a_, b_) a_ ## b_ | |
#define CONCAT2(a_, b_) CONCAT(a_, b_) | |
#define UNIQUE_TOKEN(var_) CONCAT2(var_, __LINE__) | |
#define DEFER \ | |
auto void UNIQUE_TOKEN(defer_foo)(char *); \ | |
__attribute__((unused, cleanup(UNIQUE_TOKEN(defer_foo)))) char UNIQUE_TOKEN(defer_var); \ | |
void UNIQUE_TOKEN(defer_foo)(char *unused __attribute__((unused))) | |
#endif // _DEFER_H_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment