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
David Wilkinson - 26 Apr 2007 00:47 GMT
> 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:
[quoted text clipped - 4 lines]
> VS2005 is complaining that 'exception' isn't recognized... anyone know
> what the resolution is to this?
Michael:
#include <exception> ??
using namespace std; ??

Signature
David Wilkinson
Visual C++ MVP
Bruno van Dooren - 26 Apr 2007 07:27 GMT
>> 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
[quoted text clipped - 10 lines]
> #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.

Signature
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
bruno_nos_pam_van_dooren@hotmail.com
Michael Bray - 26 Apr 2007 15:42 GMT
Yup - it was the std:: namespace... Thanks everyone!
-mdb
>> #include <exception> ??
>> using namespace std; ??
[quoted text clipped - 4 lines]
> I seem to remember) they are in std. That why you are getting those
> errors.
adebaene@club-internet.fr - 26 Apr 2007 09:29 GMT
On Apr 25, 9:37 pm, Michael Bray
<mbrayATctiusaDOT...@you.figure.it.out.com> 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:
[quoted text clipped - 4 lines]
> 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