3 ms·
To the point of having something similar to defer in C. Gnu C has attribute cleanup[1][2] which is supported by both GCC and Clang. Sure its not portable in th
by hsaliak 8y ago
To the point of having something similar to defer in C. Gnu C has attribute cleanup[1][2] which is supported by both GCC and Clang.
Sure its not portable in the strictest sense but these two compilers offer wide enough support that may be sufficient for your use case. systemd uses it, for example.
glib is also a good general purpose library, you do not need to use GObject or it's event loop to make use of it.
[1] http://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html http://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes...
[2]http://echorand.me/site/notes/articles/c_cleanup/cleanup_attribute_c.html http://echorand.me/site/notes/articles/c_cleanup/cleanup_att...
- jorangreef 8y agoZig (a modern, safer C) has defer: https://ziglang.org/documentation/master/#defer https://ziglang.org/documentation/master/#defer