From: anandnld <ana...@de...> - 2007-04-09 12:45:52
|
Brian Dessent wrote: > > anandnld wrote: > >> Im using MinGw gcc compiler. In my program im using 3 files. >> 1. Header file >> 2. Definition file for the functions in header file >> 3. Accessing those methods in 3rd file >> >> While accessing the methods from 2nd file, some memory exceptions are >> occuring. im not able to catch those exceptions. Can any one help in >> that.... >> [...] >> while accessing the method in 3 file memory reference error occured as >> "The >> instruction at "0x7c812009" referenced momory at "0x00000000". The memory >> could not be "read". while running and control exits there itself. How to >> exception from my 3rd file. NOT TO CATCH THE EXCEPTION IN 2nd FILE. > > This is almost certainly a bug in your getValue function, that's doing > something it shouldn't (in this case dereferencing a NULL pointer.) You > should fix that, and not try to catch the exception. > > You may be getting confused about the different kind of exceptions. C++ > provides exceptions as part of the langauge, in the form of try/catch. > This is a *language* thing, completely independant of the operating > system, implemented entirely by the compiler. The only exceptions you > will catch here are ones that your C++ code or the STL explicitly > throws. You won't get anything from the operating system. > > The operating system itself has a completely separate and unrelated kind > of exception, called SEH (structed exception handling.) This is a > *language-indedepent* thing provided by the OS and can be utilized by > any kind of code, C, C++, assembler, whatever. This is where you catch > invalid access faults and Ctrl-C events and so on. The Microsoft > toolchain implements __try/__except/__finally in order to directly > access these SEH functions from C or C++. Note that these are entirely > different from C++ exceptions! However the MS toolchain implements C++ > exceptions using SEH, so they are related; but that's an implementation > detail. > > The GNU toolchain does not (yet) speak SEH, sadly. It implements C++ > exceptions using either setjmp/longjmp (SJLJ) or Dwarf-2, sometimes > called no-cost exception handling because unwinding is done by looking > at tables stored in the debug information on how to unwind the frame, > which happens only when an exception occurs. > > However, since SEH is an operating system-provided feature, you can > still make use of some of its features even without compiler support. > This is all documented on MSDN, see > <http://msdn2.microsoft.com/en-us/library/ms680657.aspx>. In your case, > the popup error message that you are seeing is a result of the system's > default unhandled exception filter stepping in to handle the fault. You > can use SetUnhandledExceptionFilter() to install your own exception > handler and deal with the fault. > > Brian > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > > ----------------------------------------------------------------------------------------------------------------------------------- Hi Brain, Thanks for replying Brain. getValue() function is not defined my me. Its defined by users and I have to access those function from my third file. Even though the persons who defining the function makes mistake on "out of array", "Getting into infinite loop" and etc., can we able to access it ..... In my third file I will call that function by passing various inputs and wants to call atleast 10 times and want to check for the output from that function as correct or wrong. By checking as like that, in between if any runtime error occurred entire program crashes. How can handle it without crashing...... By Anandnld Thats my problem................... -- View this message in context: http://www.nabble.com/How-to-use-try-catch-exception-in-MinGw-tf3505448.html#a9901696 Sent from the MinGW - User mailing list archive at Nabble.com. |