Compiler exception switches

At this point, it is worth explaining why you have compiled your code with the /EHsc switch. The simple answer is, if you do not use this switch the compiler will issue a warning from the Standard Library code, and as the Standard Library uses exceptions you must use the /EHsc switch. The warning tells you to do this, so that is what you do.

The long answer is that the /EH switch has three arguments that you can use to influence how exceptions are handled. Using the s argument tells the compiler to provide the infrastructure for synchronous exceptions, that is, C++ exceptions that may be thrown in a try block and handled in a catch block, and that have stack unwinding that calls the destructors of automatic C++ objects. The c argument indicates that extern C functions (that is, all the Windows SDK functions) never throw C++ exceptions (and hence the compiler can do an additional level of optimization). Hence, you can compile Standard Library code with either /EHs or /EHsc, but the latter will generate more optimized code. There is an additional argument, where /EHa indicates that the code will catch both synchronous and asynchronous exceptions (SEH) with try/catch blocks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset