Re: Unhandled exception - How to turn off!
- From: "David F." <df2705@xxxxxxxxxxxxxxxx>
- Date: Tue, 20 Mar 2007 14:37:21 -0700
I don't use exception handling and things like failed memory allocations
(new()) failures are expected and handled internally. I tried setting
the VS2005 ide setting for C++ Exception Handling to No yet when new()
fails it throws up a screen about a run-time error. If running in the
VS2005 environment, you get
"Unhandled exception at 0x12345 in progname.exe: Microsoft C++ exception:
std::bad_alloc at memory location 0x121345"
Continue or Break. I can continue and continue and the program runs
fine.
So how to I turn off all Exception Handling so it's not used at all???
You want new to return NULL in case of failure instead of throwing?
You're now (since C++03 I think) supposed to do:
new (std::nothrow) T[N];
to get that functionality.
There are some tricks you can do to get that behavior process-wide without
editing every line of code, but you have to ask whether you want to have
code that's unmaintainable because it doesn't follow the standard.
If you decide putting std::nothrow on each allocation is too much effort,
post again and we'll see about activating the old behavior.
I found:
"If you still want the non-throwing version of new for the C Runtime
Library, link your program with nothrownew.obj. However, when you link with
nothrownew.obj, new in the Standard C++ Library will no longer function."
That took care of it.
You'd think they would have left new alone for all the existing code and had
it "new (std::throw) T[N]" instead. (or something easier to type).
.
- Follow-Ups:
- Re: Unhandled exception - How to turn off!
- From: Alexander Grigoriev
- Re: Unhandled exception - How to turn off!
- From: Tom Widmer [VC++ MVP]
- Re: Unhandled exception - How to turn off!
- References:
- Unhandled exception - How to turn off!
- From: David F.
- Re: Unhandled exception - How to turn off!
- From: Ben Voigt
- Unhandled exception - How to turn off!
- Prev by Date: A simple problem with an abstract class...
- Next by Date: Re: A simple problem with an abstract class...
- Previous by thread: Re: Unhandled exception - How to turn off!
- Next by thread: Re: Unhandled exception - How to turn off!
- Index(es):
Relevant Pages
|
Loading