3 ms·
Like the article mentioned, GCC, clang & icc all have the __cleanup__ attribute that can call a destructor for when a value moves out of scope. (And works prett
by shakna 5y ago
Like the article mentioned, GCC, clang & icc all have the __cleanup__ attribute that can call a destructor for when a value moves out of scope. (And works pretty much how it would in C++). MVSC is really the only one missing it of the major compilers, but it doesn't implement half the actual standard anyways.
__cleanup__ might be a C extension, but it's pretty widely supported. If you really wanted to have it be a code block instead of a function, in plain C, then you could possibly also use clang or GCC's lambda-ish extensions.