[英]How can I tell if the Microsoft C++ code I'm running was compiled with the /EHa switch?
I need to make sure the header I'm using is compiled with the /EHa compiler switch? 我需要确保正在使用的标头是使用/ EHa编译器开关编译的吗?
How can I do that? 我怎样才能做到这一点?
inline bool CodeHasEHaSwitch()
{
bool dtorCalled = false;
struct CCheckEHaSwitch
{
CCheckEHaSwitch( bool& dtorCalled) : dtorCalled( dtorCalled ) {}
~CCheckEHaSwitch() { dtorCalled = true; }
bool& dtorCalled;
static void Win32ExceptionTranslator( unsigned int nExceptionCode,
EXCEPTION_POINTERS *pExceptionInfo )
{ throw nExceptionCode; }
};
_se_translator_function pfnPrevSeTranslator =
_set_se_translator( CCheckEHaSwitch::Win32ExceptionTranslator );
try
{
CCheckEHaSwitch test( dtorCalled );
*((int*)0) = 0; // generate access violation
}
catch (unsigned int)
{
}
_set_se_translator( pfnPrevSeTranslator );
return dtorCalled;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.