Re: try/catch with new rtti & /GX doesn't want to catch exception...
- From: russellk@xxxxxxxxxxxxxxxxxxxx ("Russ Keldorph [MS]")
- Date: Wed, 22 Jun 2005 21:53:09 GMT
You can use SEH in C++ code. You just can't mix C++ EH with SEH in the
same function. I don't want to get into a philosophical debate about
proper style, but I'll give you my recommendation. SEH should only be used
in two cases:
1) Wrapping very short sequences of code where you have no control over
whether the code causes an exception, but you must simply ignore an
exception if it happens. Typically this means calls out to library code
you don't control. This is generally bad practice because the library can
be left in an inconsistent/insecure state, but sometimes production code
simply has no alternative.
2) Wrapping entire programs/threads, i.e. the __try should be at the base
of a callstack. This is the typical case where you would rather perform
some sort of graceful shutdown/restart if something unexpected happens.
The exception is usually considered unrecoverable and the current process
should end in any case. This use is less evil since the process will end
shortly, but since the process could still be in an inconsistent state,
really anything you do could be bad.
For both of these cases, it's trivial to place the SEH __try in its own
function.
To address your question, the fact is that we (MS compiler weenies) do
everything we can to ensure /EHa does what you want in terms of catching
SEH, and it does work in almost all cases. However, the problem is
extremely complicated and we find corner cases that aren't covered often
enough that we don't recommend using it for that purpose. Instead, stick
to SEH, which is a bit simpler and was actually designed for that purpose.
--
Russ Keldorph
russellk@xxxxxxxxxxxxxxxxxxxx (Remove the 'online.' from my address to
reach me.)
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
--------------------
> From: "Steve Maillet \(eMVP\)" <nospam1@xxxxxxxxxxxxxxxxxxxxxxx>
> References: <1118945119.413991.226360@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
<9DS2BL1dFHA.3404@xxxxxxxxxxxxxxxxxxxxx>
> Subject: Re: try/catch with new rtti & /GX doesn't want to catch
exception...
> Date: Wed, 22 Jun 2005 14:01:14 -0400
> Lines: 12
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
> X-RFC2646: Format=Flowed; Original
> Message-ID: <#1iKpR1dFHA.640@xxxxxxxxxxxxxxxxxxxx>
> Newsgroups: microsoft.public.windowsce.embedded.vc
> NNTP-Posting-Host: cpe-204-210-85-141.maine.res.rr.com 204.210.85.141
> Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
> Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.windowsce.embedded.vc:9673
> X-Tomcat-NG: microsoft.public.windowsce.embedded.vc
>
> Well, hang on then. We are not supposed to mix SEH with C++ exception
> handling so how are we supposed to write code that can catch SEH
exceptions
> in C++ code? If /EHa isn't going to guarantee I can catch any SEH
exception
> then the whole thing is rather seriously flawed in my view.
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
> smaillet at EmbeddedFusion dot com
>
>
>
.
- Follow-Ups:
- Re: try/catch with new rtti & /GX doesn't want to catch exception...
- From: Steve Maillet \(eMVP\)
- Re: try/catch with new rtti & /GX doesn't want to catch exception...
- References:
- try/catch with new rtti & /GX doesn't want to catch exception...
- From: caronte
- RE: try/catch with new rtti & /GX doesn't want to catch exception...
- From: "Russ Keldorph [MS]"
- Re: try/catch with new rtti & /GX doesn't want to catch exception...
- From: Steve Maillet \(eMVP\)
- try/catch with new rtti & /GX doesn't want to catch exception...
- Prev by Date: Re: MS EVC Compiler Error
- Next by Date: Re: try/catch with new rtti & /GX doesn't want to catch exception...
- Previous by thread: Re: try/catch with new rtti & /GX doesn't want to catch exception...
- Next by thread: Re: try/catch with new rtti & /GX doesn't want to catch exception...
- Index(es):
Relevant Pages
|