3 ms·
> you can jump anywhere, not limited to the same function Outside of the current function, yes. Anywhere, no. Longjmp allows you to return to places you’ve al
by begriffs 7y ago
> you can jump anywhere, not limited to the same function
Outside of the current function, yes. Anywhere, no.
Longjmp allows you to return to places you’ve already been and have saved with setjmp. Also attempting to longjmp to a function that has since returned is undefined behavior. Thus longjmp’s usual use case is like exceptions in other languages, going back up the call chain, skipping intermediate functions.