exemple a la con d'utilisation des SEH
Code :
- __try
- {
- const CObject* pObj = reinterpret_cast<const CObject*>(pPtr);
- if(pObj && pObj->m_dwObjId == OBJID)
- return pObj;
- else
- return 0;
- }
- __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
- {
- DPF("Object - Bad pointer Caused Access Violation" );
- return 0;
- }
|
Au niveau du coût c'est peu cher (remplacement du pointeur vers le exception handler à la volée)
Attention aux constructeurs/destructeurs C++, mais il y a un warning en general.
LeGreg
Message édité par LeGreg le 30-01-2004 à 03:54:52