2 ms·
Very cool! I wasn't aware of the cleanup attribute, can't wait to try it out: The cleanup attribute runs a function when the variable goes out of scope. This a
by alxmdev 10y ago
Very cool! I wasn't aware of the cleanup attribute, can't wait to try it out:
The cleanup attribute runs a function when the variable goes out of scope. This attribute can only be applied to auto function scope variables; it may not be applied to parameters or variables with static storage duration. The function must take one parameter, a pointer to a type compatible with the variable. The return value of the function (if any) is ignored.
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attribute...
- jagger11 10y agoFYI - here's defer implementation for both gcc/clang - http://pastebin.com/EXZuRAdT http://pastebin.com/EXZuRAdT