2 ms·
No... you can only longjmp if the jmp_buf corresponds to a setjmp created within a function call which hasn't returned yet and in the same thread. I would call
by klodolph 9y ago
No... you can only longjmp if the jmp_buf corresponds to a setjmp created within a function call which hasn't returned yet and in the same thread. I would call this a primitive form of structured programming with some serious limitations--it's kind of like throwing an exception, but more primitive, and it's kind of like the Common Lisp block/return-from, except less convenient, and it's kind of like call/cc but with a bunch of limitations added.
You can do some dangerous things with longjmp to implement coroutines, but it's horribly non-portable.