Try - Catch VC6.0 VS VC2k5
-
Hi all. Due to an upgrade to Vista, I'm also upgrading my projects from VC++ 6.0 to VC++ 2K5. I have a strange problem, probably due to my limited knowledge of Vista / VC++ 2K5. Say I have this code compiled with VC++ 6.0:
CDialog* pDialog = NULL; try { pDialog->Detach(); } catch(CException* e) { e->Delete(); } catch(...) { }
No problem at all, the exception is handled. If I compile the same code with VC++ 2K5, I get a second chance exception. Both in debug en release versions. How come?----------------------- "Hey, Eddie, can I pour you a beer?" "A little early, isn't it, Richy?" "For a beer?" "No, for stupid questions."
-
Hi all. Due to an upgrade to Vista, I'm also upgrading my projects from VC++ 6.0 to VC++ 2K5. I have a strange problem, probably due to my limited knowledge of Vista / VC++ 2K5. Say I have this code compiled with VC++ 6.0:
CDialog* pDialog = NULL; try { pDialog->Detach(); } catch(CException* e) { e->Delete(); } catch(...) { }
No problem at all, the exception is handled. If I compile the same code with VC++ 2K5, I get a second chance exception. Both in debug en release versions. How come?----------------------- "Hey, Eddie, can I pour you a beer?" "A little early, isn't it, Richy?" "For a beer?" "No, for stupid questions."
If you want to catch SEH exceptions like that (the C++ way) then you can enable it... Project/Properties/C++/Code Generation/enable C++ exceptions set to Yes with SEH exceptions (/EHa) Mark
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."
-
If you want to catch SEH exceptions like that (the C++ way) then you can enable it... Project/Properties/C++/Code Generation/enable C++ exceptions set to Yes with SEH exceptions (/EHa) Mark
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."
Thanks. Works with that option. Actually, that's kind off silly. The code clearly states I want to catch exceptions. It makes no sense that you also have to enable an option to do what you've written in code. Hope there aren't many of these pitfalls. Any article on stuff like this so I can educate myself?
----------------------- New and improved: kwakkelflap.com "Hey, Eddie, can I pour you a beer?" "A little early, isn't it, Richy?" "For a beer?" "No, for stupid questions."
-
Thanks. Works with that option. Actually, that's kind off silly. The code clearly states I want to catch exceptions. It makes no sense that you also have to enable an option to do what you've written in code. Hope there aren't many of these pitfalls. Any article on stuff like this so I can educate myself?
----------------------- New and improved: kwakkelflap.com "Hey, Eddie, can I pour you a beer?" "A little early, isn't it, Richy?" "For a beer?" "No, for stupid questions."
More info ... Exception Handling: Default Synchronous Exception Model[^] /EH (Exception Handling Model)[^]
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."