By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

'exception' object in VS2005?

P: n/a
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
Apr 25 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Michael Bray wrote:
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; ??

--
David Wilkinson
Visual C++ MVP
Apr 25 '07 #2

P: n/a
>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; ??
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.

--
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
br**********************@hotmail.com
Apr 26 '07 #3

P: n/a
On Apr 25, 9:37 pm, Michael Bray
<mbrayATctiusaDOT...@you.figure.it.out.comwrote:
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
Apr 26 '07 #4

P: n/a
Yup - it was the std:: namespace... Thanks everyone!

-mdb
>#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.
Apr 26 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.