Hacker News new | ask | show | jobs
by earenndil 2286 days ago
Author of the library here; AMA.
1 comments

Why not use __attribute__((cleanup))? It's widely used in real code (eg. systemd has been using it for years) and there's effort going on to get the mechanism standardized in the next C standard.
Where's the effort? I happen to follow WG14 proposals closely, but I haven't seen this particular one discussed prominently or incorporated into the latest working draft. I don't even remember a single paper with this feature submitted to WG14 for consideration.
You need to use nested functions if you want to have nontrivial behaviour in a cleanup, and nested functions are awful in c.
So don't have nontrivial behavior in a cleanup? That sounds about as antithetical to C as nested functions.
How is support across compilers? Do clang and MSVC support it?
Does MSVC support C99 yet? Much less C11 or a future C2x?

Their priority has always been C++ and for some time their stance on C was basically "I guess we're willing to compile the subset of C that is valid C++."

GCC and Clang yes.

Do people even use MSVC to compile C (not C++) code? Last I heard it was years behind on the C standards. In any case few in the Linux community care too much about closed source compilers. Lack of MSVC support for cleanups would be amongst the least of your problems if you were trying to use it to compile systemd or libvirt.