CHU said:
Is it safe to call longjmp from a window procedure to jump to WinMain?
The jump is from wndproc to WinMain , through DispatchMessage.
I'm worried about is there some memory leaks or resource leaks occured
in DispatchMessage.
Sorry, this sounds like gibberish round here; a newsgroup
appropriate to your implementation (platform, os, compiler, ...)
may be a better place to ask for specifics.
What can be told about setjmp/longjmp from the standard
point of view:
,----
| 7.13 Nonlocal jumps <setjmp.h>
|
| 1 The header <setjmp.h> defines the macro setjmp,
| and declares one function and one type, for
| bypassing the normal function call and return
| discipline.207)
+---
| 207) These functions are useful for dealing with
| unusual conditions encountered in a low-level
| function of a program.
+---
|
|
| 2 The type declared is
| jmp_buf
| which is an array type suitable for holding the
| information needed to restore a calling environment.
| The environment of a call to the setjmp macro
| consists of information sufficient for a call to the
| longjmp function to return execution to the correct
| block and invocation of that block, were it called
| recursively. It does not include the state of the
| floating-point status flags, of open files, or of
| any other component of the abstract machine.
|
| 3 It is unspecified whether setjmp is a macro or an
| identifier declared with external linkage. If a macro
| definition is suppressed in order to access an actual
| function, or a program defines an external identifier
| with the name setjmp, the behavior is undefined.
|
`----
So, you can lose open files, have memory leaks even for
auto variables, etc. If this is safe enough for you...
Cheers
Michael