Skip to main content
gamedev.net
🔒 Locked

MSVCC + xalloc = ?

Started by RabidOcelot May 16, 2004 at 5:58 PM 3 replies 550+ views
Original Post
RabidOcelot
RabidOcelot
I''m used to allocating new variables something like this:
#include <except.h>

int *intPtr = NULL;

try
{
   intPtr = new int;
}
catch (xalloc)
{
   // Handle exception

}
However, the free VC++ 2003 toolkit + platform SDK doesn''t seem to include except.h, or anything that defines xalloc. Is there some way around this?
ChaosEngine
ChaosEngine
I think the exception type is std::bad_alloc.
what compiler where you using before?
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Programmer One
Programmer One
That header was something that came with your compiler.
psykr
psykr

int* NewInt = 0;
try {
NewInt = new int;
}
catch( std::bad_alloc& ) {
abort();
}

I''m not sure about VC2k3, but in VC6 new doesn''t actually throw an exception, but just returns 0 when it fails, so if that''s the case you should look out for it.
RabidOcelot
RabidOcelot
Thanks all.

I think this worked in Borland C++ (~5.02), but I''ve gone through a couple of compilers since then (Dev-C++ and Open Watcom), so no certainty there.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.