Re: MFC Exception TRY/CATCH without the braces { } can compile
On Wed, 13 Jun 2007 21:56:47 -0700, learnyourabc <learnyourabc@yahoo.com>
wrote:
I have some legacy programs from the prehistoric era that's still
using the old MFC exception.
That is old. The macros pretty much fell by the wayside with VC 2.0, which
came out in 1994 or so, and was the first version to implement real C++
exceptions. The MFC exception macros were originally created to simulate
exceptions using setjmp/longjmp, which among other shortcomings, didn't
unwind the stack and destroy local variables during "exception" handling.
So I guess the safest way to go is to first Use the c++ try catch and
delete the exception or if let the MFC exception remain is to never
delete the exception inside TRY CATCH MFC exceptions so that you don,t
have exception in END CATCH from deleting the exception twice, but
dosen,t it check first before deleting in the END CATCH
AfxTryCleanup() Anyway, Thanks a lot esp to Arman & Doug for
clarfying.
If the macros are working fine in your existing code, I wouldn't bother
replacing them; MFC itself continues to use them internally. As for new
code, you can use whatever you want, but it's recommended that you use the
try/catch keywords. Among other things, they accommodate non-MFC exception
types, such as the standard library's std::exception, the compiler COM
support _com_error, etc. I wrote a little about that here:
http://members.cox.net/doug_web/eh.htm#Q6
--
Doug Harrison
Visual C++ MVP