How to implement software exception handling

The exception types list contains one or more type names, separated by commas. Handlers that are organized within try blocks catch the exceptions. The difference between the Microsoft extensions and the ISO standard is the way these mechanisms handle the exception.

Solution
Use the switch for asynchronous exception handling.
Microsoft can customize their exception handling to a specific compiler and operating system, so the way it is handled can be implemented at the operating system (OS) level. This makes their method more efficient and eliminates the need to duplicate the exception raising and handling software in each individual piece of code. Rather, the C/C++ runtime can handle it. The ISO C++ exception-handling standard, on the other hand, is compiler- and OS-agnostic. Therefore, it needs to compile and link in extra code into each binary that provides software exception handling.

Although the Intel C++ compiler provides the functionality of both the SEH and ISO exception-handling model, you must make sure that the compiler switch for asynchronous exception handling is on. Otherwise, the following code (for example) compiles without warnings on the Intel Compiler using the Microsoft Exception model:


w__try

   Instruction that generates an exception
   return true;

__except(1)
   
   return false;
   


If you do not use the asynchronous exception switch for the compiler, it will not catch the exception in the except statement and will be left as an exception for the runtime to handle, causing the program to exit. However, if you were to implement the code as follows, using the ISO exception model, it will add extra code within your program to handle the exception (bypassing the runtime).


try

   Instruction that generates an exception
   return true;

catch(?)
   
   return false;

Source
"Software Exception Handling," by Rich Winterton.

© 2005 Intel Corp.

Get a pdf version of this article: click download, below.


Subscribers who liked this article also read:
Integrating Java and Microsoft .NET
by Jon Jagger, Content Master Ltd. Intel Corp. The right techniques...
Multithreaded technology and multi-core processors
by Craig Szydlowski, Infrastructure Processor Division, Intel Corp. ...

If you're interested in this topic, these articles may be helpful:

Intel® Threading Building Blocks (TBB)
Intel® Threading Building Blocks (TBB) offers a rich and complete ...
Managing exceptions in Web services environments
from AmberPoint Inc. Web services present us with a standards-base...
Intel® TBB for Open Source
Threading Building Blocks (TBB) is an award-winning C++ runtime librar...
Practical C++ Programming, 2nd Edition
by Steve Oualline, O'Reilly Media Inc. C++ is a powerful, highly fl...
DevPartner for Visual C++ BoundsChecker Suite
DevPartner for Visual C++ BoundsChecker Suite is a powerful set of sof...

Related Jobs:

Build Management #141602 - WA - Redmond - Microsoft Corporation
Are you an experienced lead looking for the next big opportunity? Wind...
Programming Writer #142248 - WA - Redmond - Microsoft Corporation
Have you wondered why searching for a workbook is different than searc...
Software Development Engineer in Test #133984 - WA - Redmond - Microsoft Corporation
Imagine being able to find the pictures your friend shared without kno...
Software Development Engineer #139806 - WA - Redmond - Microsoft Corporation
Want to be part of the exciting fast-growing Mobile Devices business? ...
Programming Writer #143659 - WA - Redmond - Microsoft Corporation
Purpose: MEDPG is where world-class platforms are created for embedded...
Microsoft Engineer - CIN #255356 - OH - Cincinnati - Berbee Information Network Corp
Microsoft Engineer - CIN Oct 4, 2005 Cincinnati,Ohio Send Job ...
Programming Writer #143660 - WA - Redmond - Microsoft Corporation
MEDPG is where world-class platforms are created for embedded and mobi...
Network Voice Engineer - CIN #101273 - OH - Cincinnati - Berbee Information Network Corp
Network Voice Engineer - CIN Sep 20, 2005 Cincinnati,Ohio Send...
Software Development Engineer #137871 - WA - Redmond - Microsoft Corporation
Do you use Internet Explorer every day and find yourself wishing for m...
Software Development Engineer in Test #140110 - WA - Redmond - Microsoft Corporation
Do you love using the latest DIGITAL MEDIA technology that Microsoft h...