'exception' object in VS2005?

M

Michael Bray

I'm converting a project from VS2003 to VS2005, and one of the most common
errors that I'm getting is on my try/catch blocks, where I used to do:

try { ... }
catch (exception &e) { ... }

VS2005 is complaining that 'exception' isn't recognized... anyone know
what the resolution is to this?

TIA!

-mdb
 
D

David Wilkinson

Michael said:
I'm converting a project from VS2003 to VS2005, and one of the most common
errors that I'm getting is on my try/catch blocks, where I used to do:

try { ... }
catch (exception &e) { ... }

VS2005 is complaining that 'exception' isn't recognized... anyone know
what the resolution is to this?

Michael:

#include <exception> ??
using namespace std; ??
 
B

Bruno van Dooren

I'm converting a project from VS2003 to VS2005, and one of the most
Michael:

#include <exception> ??
using namespace std; ??

I had the same problem once, and you'd have the same problem if you migrate
from VC2003 to gcc.
In VC2003, exceptions are in the global namespace. In VC2005 (and gcc I seem
to remember) they are in std. That why you are getting those errors.
 
A

adebaene

I'm converting a project from VS2003 to VS2005, and one of the most common
errors that I'm getting is on my try/catch blocks, where I used to do:

try { ... }
catch (exception &e) { ... }

VS2005 is complaining that 'exception' isn't recognized... anyone know
what the resolution is to this?

If you are using the STL class, then it is in the std namespace : use
catch(std::exception& e)

Arnaud
MVP - VC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top