|
|
||||||
|
#1
|
|
|
|
|
Hello everyone,
I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my test code and I am using Visual Studio 2008. [Code] #include <iostream> using namespace std; int main() { int* address = NULL; try{ (*address) = 1024; } catch (...) { cout << "access violation caught" << endl; } return 0; } [/Code] thanks in advance, George EggHeadCafe - .NET Developer Portal of Choice [url down] |
|
|
|
#2
|
|
|
|
|
Hi George,
>Any comments? first at all: This is NOT a Newsgroup for discussions about language and language concepts. >[Code] >#include <iostream> >using namespace std; >int main() { >int* address = NULL; >try{ >(*address) = 1024; >} catch (...) >{ >cout << "access violation caught" << endl; >} >return 0; >} >[/Code] What you use here is not SEH, it is C++ exception handling, though they internally map to SEH (i think Volodymyr said that already somewhere here)! Read the documents carefully before you post anything! By the way: You ask questions for anything that is answered already in the MSDN Library or in some newsgroups. First do a extensive search and after being not able to find something, then ask and not everything that is unclear to you. There are beginner NG's tailored for your questions and there are lots of them out there. Try to ask your questions there, because it is more obvious to get a answer there than here. Regards Kerem |
|
#3
|
|
|
|
|
<George George> wrote in message
news:emic > Hello everyone, >> I have tested try-catch works with structured exception, to my surprise. > Previously I think we have to use __try and __except. > > Any comments? Here is my test code and I am using Visual Studio 2008. You're in the realm of needing to list the compile command line. catch(...) will be an SEH when compiling with /EHa, but not with /EHsc [..] |
|
#4
|
|
|
|
|
> You're in the realm of needing to list the compile command line.
> > catch(...) will be an SEH when compiling with /EHa, but not with /EHsc And by default, VS2008 uses /EHsc, so George's code should fail with access violation. |
|
#5
|
|
|
|
|
With VS2003, the only exception handling options from the integrated
environment for /EHz and "none". Using /EHz, the default, catches both C++ and SEH. In VS2005 (and 2008), the behavior is different as that compiler setting doesn't catch SEH. It also gives the option of /EHz in the integrated environment, which will catch both types of exceptions. Minor pain in the butt. "Volodymyr Shcherbyna" <v_scherbina> wrote in message news:1132 [..] |
|
|
| Similar Threads | |
| Handle C++ exception and structured exception together Hello everyone, I am learning set_se_translator, and there are some good resources about how to translate structured exception into C++ exception, like, [..] 1. What... |
|
| Try-catch works with structured exception Hello everyone, I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my... |
|
| Try-catch works with structured exception Hello everyone, I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my... |
|
| Does Sun's Windows JVM catch Win32 Structured Exceptions? Hi I have a java program running on a windows platform which makes calls to an external product (dll, .NET) through JNI. In most cases where an exception is generated in... |
|
| Getting the exception code from a structured exception in a catch (...) block In my program I'm throwing C++ exceptions all around and need to catch structured exceptions and re-throw them as C++ exceptions. I've managed to do it, but it's a bit... |
|
|
All times are GMT. The time now is 11:50 AM. | Privacy Policy
|