5 ms·
Using the __cleanup__ variable attribute in GCC
- buserror 11y agoActually 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!
- zvrba 11y ago"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++.
- Gibbon1 11y agoOnce 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.
- cremno 11y agosystemd does that: https://github.com/systemd/systemd/blob/v224/src/basic/macro.h#L48 https://github.com/systemd/systemd/blob/v224/src/basic/macro... https://github.com/systemd/systemd/blob/v224/src/basic/macro.h#L477-L482 https://github.com/systemd/systemd/blob/v224/src/basic/macro... https://github.com/systemd/systemd/blob/v224/src/basic/util.h#L491-L520 https://github.com/systemd/systemd/blob/v224/src/basic/util.... https://github.com/systemd/systemd/blob/v224/src/basic/fileio.c#L43-L44 https://github.com/systemd/systemd/blob/v224/src/basic/filei...
- castratikron 11y agoI 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.
- saisi 11y agoPretty cool. Does anyone have recommendations on great books that cover advanced C internals (other than K&R) and/or GNU extensions for C?
- bleakgadfly 11y agoExpert C Programming: Deep Secrets (http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp/0131774298 http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp...) Advanced C: Tips and Techniques (http://www.amazon.com/Advanced-Techniques-Hayden-Books-Library/dp/067248417X http://www.amazon.com/Advanced-Techniques-Hayden-Books-Libra...)
- revelation 11y agoOr, 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.
- slrz 11y agoNah. 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++.