3 ms·
You can't use longjmp/setjmp - http://en.cppreference.com/w/cpp/utility/program/longjmp http://en.cppreference.com/w/cpp/utility/program/longjmp There are seve
by malkia 13y ago
You can't use longjmp/setjmp - http://en.cppreference.com/w/cpp/utility/program/longjmp http://en.cppreference.com/w/cpp/utility/program/longjmp
There are several popular "C" libraries that use them - jpeglib comes to mind, but there are others. Also certain language's runtime environment uses it. There is a way to handle it, but you need to take care.
- mihai_ionic 13y agoEven in C, setjmp/longjmp leave all non-volatile automatic storage duration variables on the current stack frame in an indeterminate state if they are modified between the two calls. To get defined behaviour with regards to destructors, you simply have to make sure that the function calling setjmp doesn't internally use RAII. Call a wrapper function to do the setjmp and you're safe. Of course it's a whole other question whether using setjmp/longjmp to implement "exception handling in C" is a good idea in the first place.