Every time I want to do some C programming on projects which do not depend on I end up missing the g_auto* convenience. Today I got tired of the situation and ended up writing my own, single-header, MIT-licensed, cleanroom implementation, which can be just copy-pasted in any C project → github.com/aperezdc/autocleanu

(Of course it still requires that the compiler supports GCC's “__attribute__((cleanup(f)))”, but that's fine by me.)

That autocleanup thingy, I made it for github.com/aperezdc/ltree which is in very early stages, but I plan it to have a “remove all files listed in this mtree manifest”, which I am totally going to use to implement a poor man's package manager. Or, in other words: in combination with “fakeroot” to keep track of what stuff a random “make install” writes to the filesystem, and being able to do nice things with that.


In retrospective, it's a lot of fun doing cute small tools in now and then, specially when a good amount of my daily work is staring at tens of thousands of C++ WebKit code. Which is also amazing in its own ways, but hey, come on... It's C++ 😔

Also, note to self: I haven't been doing lately, and not all can be just coding. Maybe tomorrow!

Sign in to participate in the conversation

Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. This server is run by the main developers of the Mastodon project. Everyone is welcome as long as you follow our code of conduct!