4 ms·
Sounds like you're trying to emulate the "cleanup" GCC variable attribute: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html https://gcc.gnu.o
by eqvinox 7y ago
Sounds like you're trying to emulate the "cleanup" GCC variable attribute:
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attribute...
Example use:
https://github.com/FRRouting/frr/blob/master/lib/frr_pthread.h#L218-L264 https://github.com/FRRouting/frr/blob/master/lib/frr_pthread...
(FRR requires a GCC/clang compatible compiler, so no fallback/workaround.)
- CameronNemo 7y agoLXC also uses this attribute.
- loeg 7y agoGCC attribute cleanup is so much harder to misuse than some hodgepodge macro construction like this. If you're a C developer, it is by far the superior option. Clang supports it, of course.
- rwmj 7y agoIt's also used in several important big Linux programs so it's unlikely to be going away. There have been efforts to get the mechanism added to the next C standard too.
- loeg 7y agoRe: going away — has GCC ever removed any relatively common attribute in the past? They basically don't ever, to my knowledge. They haven't removed nested functions, for example, which would probably be a good idea. (To your point, though: important Linux programs like GRUB use nested functions.)