![](/img/trans.png)
[英]Add /EHa to QtCreator that used Microsoft Visual C++ Compiler
[英]How can I tell if the Microsoft C++ code I'm running was compiled with the /EHa switch?
我需要確保正在使用的標頭是使用/ EHa編譯器開關編譯的嗎?
我怎樣才能做到這一點?
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.