I\'m a C++ programmer and used to OO languages with good exception handling.
From what I can understand, setjmp and longjmp are essentially a c-style way to propogate ex
You certainly don't want to use setjmp
in C++, as you say that's what exceptions are for. You don't want to use them in C either because it's exceedingly hard to get right. Try very hard to find other solutions.
setjmp
and longjmp
are macros used to bypass normal function call and return flow.
The setjmp
saves the calling env to be used by longjmp
Use of these macros correctly is really hard and you can easily end up with undefined behavior.
Because of this, it is mandated for example to restrict longjmp
to 1 level of signal handler (best actually to not be called at all).
In critical systems it is required not to be used at all.