I need to write a C library which will be integrated into a C++ code base. This library may call C++ code passed as a callback. These functions may throw C++ exceptions.
I'd like to ensure that the cleanup code is run during the stack unwinding process. I could use the cleanup
attribute to ensure that:
If -fexceptions is enabled, then cleanup_function is run during the stack unwinding that happens during the processing of the exception.
From the GCC docs.
Unfortunately I can't use the cleanup attribute. I'd like to register the cleanup function to be run during stack unwinding programmatically using portable C.
Is this possible?