Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Using the __cleanup__ variable attribute in GCC (echorand.me)
24 points by implmentor on Aug 14, 2015 | hide | past | favorite | 9 comments


I learned about this a few years ago, but haven't made use of it at all. But I can see how it could be handy. I like using the vector attribute to make gcc generate vector instructions.


Actually this is pretty cool, you can make the same sort of semantics as C++ stack based objects in plain C. With a couple macros you could make it pretty much feature equivalent.

Thanks for posting that!


"Plain C" is defined by the ISO C standard. Once you start using extensions like these you're better off going over to standard C++.


Once you think you need to move from some flavor of C to standard C++ you should probably switch to a safe proper garbage collected language.



Pretty cool.

Does anyone have recommendations on great books that cover advanced C internals (other than K&R) and/or GNU extensions for C?



Or, you know, just use C++ if you want to do this.

No worries, it doesn't hurt, you won't have to use iterators and new.


Nah. I think that for many programs the GNU extensions to C provide a better tradeoff in terms of expressiveness vs. added complexity than the truckload of arbitrary features that is C++.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: