Po Lu writes: > Arsen Arsenović writes: > >> Depending on how long ago that was, it might be worth reconsidering. >> GCC has been C++ for a decade now, for instance, so C++ compilers are >> likely fairly widespread. One could make the case that using portable >> C++ in addition to portable C is a more portable way to do cleanups than >> GNU C cleanups. >> >> If still undesirable, I strongly suggest at least using GNU C cleanups. >> They are a decent workaround. > > GNU C cleanups only work when compiling with -fexceptions. This is not the case. They work under all conditions, and are used to great effect in many C codebases. As an example, the following: int f (void (*foo) (void)) { __attribute__ ((cleanup (test))) int* n = g (); foo (); } ... generates: f: pushq %rbx xorl %eax, %eax movq %rdi, %rbx subq $16, %rsp call g movq %rax, 8(%rsp) call *%rbx leaq 8(%rsp), %rdi call test /* cleanup */ addq $16, %rsp popq %rbx ret ... with -O3 -fno-exceptions. The latter is the default for C, but I wanted to be explicit anyway. > C++ is an ugly and bloated language, and not as widely available as you > think. To use it in Emacs for something as important as modules would > be a shame. It is likely as widely available as cleanup attributes. Certainly as widely as any supported (or many unsupported) versions of GCC are. I won't argue on the merits of the language, as that usually doesn't go anywhere, and the cleanup attribute seems like an accepted solution anyway. Note that it's no coincidence that it is being adopted by some GNU projects. > Either way, we don't expect to survive a C++ exception, so why cater > specifically to C++'s stack unwinding? I agree that it isn't necessary. I was just answering the question of what '-fexceptions' would do as someone with the know-how, because it was brought up. -- Arsen Arsenović