Feb 24, 2014

Exception handling and structured exception handling

Generally speaking, the distinction between a structured exception and exception handling is Microsoft’s implementation of exception handlers themselves. questionable “ordinary” C++ exception handling uses 3 statements further to the C++ language: strive, catch, and throw. the aim of those statements is to permit a piece of software system (the exception handler) to aim a secure bailout of the applying that was running once the exception occurred. The exception handler will lure exceptions on any knowledge kind, together with a C++category. The implementation of the 3 statements relies on the ISO WG21/ANSI X3J16 C++ normal for exception handling. Microsoft C++ supports exception handling supported this normal.
Note that this standard applies solely to C++ and to not C.
On the opposite hand, structured exception handling is AN extension to the Microsoft C/C++ compiler. Its single largest advantage is that it works with either C or C++. Microsoft’s structured exception handling style uses two new constructs: try-except and try-finally. These 2 constructs don't seem to be a set or superset of the ANSI C++ standard; instead, they're a unique implementation of exception handling (leave it to Microsoft to forge ahead on its own). The try-except construct is thought as exception handling, and try-finally is known as termination handling. The try-except statement permits AN application to retrieve the state of the machine once the exception occurred. this is often terribly handy for displaying info regarding the error to the user, or to be used whereas you're debugging your code. 
The try-finally statement permits applications to guarantee execution of cleanup code once traditional code execution is interrupted. Though structured exception handling has its blessings, it additionally has its drawbacks. as a result of this is often not AN ANSI customary, code using structured exception handling isn't as moveable as code victimisation ANSI exception handling. a decent rule of thumb is that if your application goes to be a C++ program, you're suggested to stay to ANSI exception handling (use the attempt, catch, and throw statements).

No comments:

Post a Comment

Thank you for your valuable comment. Stay tuned for Updates.