First of all, this is definitely about C, no C++ solutions are requested.
Target:
Return to the caller function (A
) beyond multiple stack frames.
I have some solutions, but none of them feels like the best option.
The easiest one in the sense of implementation is longjmp/setjmp, but I am not sure if it destroys auto variables, because as wiki refers, no normal stack unwinding taking part if longjmp is performed.
Here is a short description of the program flow:
the A
function calls file processing
function, which results in many internal
and recursive invocations. At some point, file reader meets EOF, so the job of
file processing
is done and control should be given to A
function.
Comparing each read character against EOF or '\0'? No, thanks. UPD: I can avoid dynamic allocations in the call chain between setjmp and longjmp.
Not being sure about auto variables, I do not know what will happen in sequential calls
to file processing
(there is more than 1 file).
So:
1) Whats about 'no stack unwinding' by longjmp? How danger is that if I got all the data holders available (pointers).
2) Other neat and effective ways to go back to the A
frame?