Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enforce Visual Studio exception handling mode

I'm using the Visual Studio /EHsc exception handling mode in my project. This means catch(...) won't catch structured exceptions. I've got a public header that does a catch(...) that can be included by consumer projects.

I'm concerned that a project consuming my header may have a different exception handling mode that will make my header misbehave.

Is there a way of static_asserting or #pragma error'ing or otherwise failing the build if the exception handling mode isn't as needed?

See: https://msdn.microsoft.com/en-us/library/1deeycx5.aspx

like image 438
Scott Langham Avatar asked Dec 08 '25 18:12

Scott Langham


1 Answers

From https://msdn.microsoft.com/en-us/library/b0084kay.aspx

_CPPUNWIND Defined as 1 if one or more of the /GX (Enable Exception Handling), /clr (Common Language Runtime Compilation), or /EH (Exception Handling Model) compiler options are set. Otherwise, undefined.

It's not perfect, but it gives you a fighting chance to get them the same

like image 200
UKMonkey Avatar answered Dec 12 '25 00:12

UKMonkey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!