Click here to Skip to main content
15,911,531 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: compile error about destructor Pin
George_George25-Jan-08 2:48
George_George25-Jan-08 2:48 
GeneralRe: compile error about destructor Pin
David Crow25-Jan-08 2:56
David Crow25-Jan-08 2:56 
GeneralRe: compile error about destructor Pin
George_George25-Jan-08 3:09
George_George25-Jan-08 3:09 
GeneralRe: compile error about destructor Pin
David Crow25-Jan-08 3:20
David Crow25-Jan-08 3:20 
GeneralRe: compile error about destructor Pin
George_George25-Jan-08 3:28
George_George25-Jan-08 3:28 
GeneralRe: compile error about destructor Pin
zengkun10025-Jan-08 3:52
zengkun10025-Jan-08 3:52 
GeneralRe: compile error about destructor Pin
George_George25-Jan-08 3:59
George_George25-Jan-08 3:59 
GeneralRe: compile error about destructor Pin
zengkun10025-Jan-08 4:23
zengkun10025-Jan-08 4:23 
I don't know which compiler you use.
My IDE is VS2008 beta 2, after I commented the line, the program compiled successfully.MSDN said that

<br />
Specifies the model of exception handling to be used by the compiler and destroys C++ objects that will go out of scope as a result of the exception. If /EH is not specified, the compiler will catch structured and C++ exceptions, but will not destroy C++ objects that will go out of scope as a result of the exception.<br />
<br />
 <br />
/EH{s|a}[c][-]<br />
 <br />
<br />
Arguments<br />
a<br />
The exception-handling model that catches asynchronous (structured) and synchronous (C++) exceptions.<br />
<br />
s<br />
The exception-handling model that catches C++ exceptions only and tells the compiler to assume that extern C functions do throw an exception.<br />
<br />
c <br />
If used with s (/EHsc), catches C++ exceptions only and tells the compiler to assume that extern C functions never throw a C++ exception. /EHca is equivalent to /EHa.<br />
<br />
Remarks<br />
Use /EHs to specify the synchronous exception handling model (C++ exception handling without structured exception handling exceptions). If you use /EHs, then your catch clause will not catch asynchronous exceptions. Also, in Visual C++ 2005, all objects in scope when the asynchronous exception is generated will not be destroyed even if the asynchronous exception is handled. Under /EHs, catch(...) will only catch C++ exceptions. Access violations and System..::Exception exceptions will not be caught.<br />
<br />
Use /EHa to specify the asynchronous exception handling model (C++ exception handling with structured exception handling exceptions). /EHa may result in a less performant image because the compiler will not optimize a catch block as aggressively, even if the compiler does not see a throw.<br />
<br />
Use /EHa if you want to catch an exception raised with something other than a throw. The following sample will generate an exception:<br />
<br />
  Copy Code <br />
// compiler_options_EHA.cpp<br />
// compile with: /EHa<br />
#include <iostream><br />
#include <excpt.h><br />
using namespace std;<br />
<br />
void fail() {   // generates SE and attempts to catch it using catch(...)<br />
   try {<br />
      int i = 0, j = 1;<br />
      j /= i;   // This will throw a SE (divide by zero).<br />
   }<br />
   catch(...) {   // catch block will only be executed under /EHa<br />
      cout<<"Caught an exception in catch(...)."<<endl;<br />
   }<br />
}<br />
<br />
int main() {<br />
   __try {<br />
      fail(); <br />
   }<br />
<br />
   // __except will only catch an exception here<br />
   __except(EXCEPTION_EXECUTE_HANDLER) {   <br />
   // if the exception was not caught by the catch(...) inside fail()<br />
      cout << "An exception was caught in __except." << endl;<br />
   }<br />
}<br />
 <br />
<br />
</excpt.h></iostream>


And access violation is called hard exception, NOT structured exception. I have said that __try __catch block indicates a structured exception.

Jeffery Richter's great book «Programming Applications for Microsoft Windows»has a good explanation about SEH Smile | :)

A Chinese VC++ programmer

GeneralRe: compile error about destructor Pin
George_George25-Jan-08 18:17
George_George25-Jan-08 18:17 
GeneralUnhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
Neels24-Jan-08 23:15
Neels24-Jan-08 23:15 
GeneralRe: Unhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
Iain Clarke, Warrior Programmer24-Jan-08 23:21
Iain Clarke, Warrior Programmer24-Jan-08 23:21 
GeneralRe: Unhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
CPallini24-Jan-08 23:21
mveCPallini24-Jan-08 23:21 
GeneralRe: Unhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
Neels24-Jan-08 23:27
Neels24-Jan-08 23:27 
GeneralRe: Unhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
CPallini24-Jan-08 23:45
mveCPallini24-Jan-08 23:45 
GeneralRe: Unhandled exception at 0x1b97d783 (mfc71d.dll) in graf.exe: User breakpoint. Pin
David Crow25-Jan-08 2:48
David Crow25-Jan-08 2:48 
QuestionMouse Hook Problem on virtual desktop Pin
sharda.bhagwatkar24-Jan-08 22:28
sharda.bhagwatkar24-Jan-08 22:28 
GeneralRe: Mouse Hook Problem on virtual desktop Pin
Iain Clarke, Warrior Programmer24-Jan-08 22:44
Iain Clarke, Warrior Programmer24-Jan-08 22:44 
GeneralRe: Mouse Hook Problem on virtual desktop Pin
sharda.bhagwatkar27-Jan-08 18:47
sharda.bhagwatkar27-Jan-08 18:47 
GeneralMDI Facelift for Vista Pin
baerten24-Jan-08 22:11
baerten24-Jan-08 22:11 
QuestionI/O run-time [modified] Pin
Hakan Bulut24-Jan-08 21:41
Hakan Bulut24-Jan-08 21:41 
QuestionRe: I/O run-time Pin
CPallini24-Jan-08 21:57
mveCPallini24-Jan-08 21:57 
GeneralMessage Closed Pin
24-Jan-08 22:14
Hakan Bulut24-Jan-08 22:14 
QuestionRe: I/O run-time Pin
CPallini24-Jan-08 22:18
mveCPallini24-Jan-08 22:18 
GeneralMessage Closed Pin
24-Jan-08 22:59
Hakan Bulut24-Jan-08 22:59 
GeneralRe: I/O run-time Pin
CPallini24-Jan-08 23:11
mveCPallini24-Jan-08 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.