by nujabes · 10y ago · 0 comments
#define _C4DEFER(code, _def) \
void _def() code; \
bool _def_trigger __attribute__((cleanup(_def))) \
#define C4DEFER(code) \
_C4DEFER(code, C4GSYM(def)) \
So, nested functions and gcc attributes.Nested functions awesome, but they're a gcc extension, and only supported on some architectures anyway, and AFAIK only work if you have an executable stack, which is frowned on these days (because they have to create a callable thunk to stash the nested function's context pointer).
http://stackoverflow.com/questions/8179521/implementation-of...
My understanding is that clang doesn't support nested functions, but it does have its own non-standard extension, blocks. But of course that's still not standard C.
I'm currently writing clunky C89 code for an old compiler (and occasionally, K&R C!), and I got really excited by this library for a moment, but... nope. Non-standard. Can't use it.
Have you had any reports about problems on, e.g., OpenBSD, related to needing an executable stack?
Nothing, but I seldom hang around in the BSD crowd these days.