00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #include "CATDebug.h"
00013 
00014 #include <stdio.h>
00015 #include <time.h>
00016 
00017 
00018 #ifdef CAT_CONFIG_WIN32
00019     
00020     
00021     
00022     void _CATAssert(   const char*   expression,
00023                        const char*   file,
00024                        CATUInt32     lineNumber,
00025                        const char*   msg)
00026     {
00027        DWORD lastError = ::GetLastError();
00028 
00029        _CATTrace(msg,file,lineNumber);
00030 
00031        char* msgString = new char[_MAX_PATH + 100 + strlen(expression) + strlen(msg)];
00032        sprintf(msgString,"%s(%d) :%s\nExpression: %s",file,lineNumber,msg,expression);
00033        DWORD result = ::MessageBoxA(NULL,msgString,"Assertion Failed",MB_ABORTRETRYIGNORE);
00034        delete [] msgString;
00035 
00036        switch (result)
00037        {
00038           case IDRETRY:
00039              
00040              
00041              
00042              _asm {int 3};
00043              break;
00044           case IDIGNORE:
00045              
00046              break;
00047           
00048           default:
00049           case IDABORT:
00050              
00051              _exit(-1);
00052              break;
00053        }
00054        
00055        SetLastError(lastError);
00056     }
00057 
00058 
00059     
00060     
00061     void _CATTrace(    const char*     msg, 
00062                        const char*     file, 
00063                        CATUInt32       lineNumber)
00064     {
00065        DWORD lastError = ::GetLastError();      
00066        
00067        char* msgString = new char[_MAX_PATH + 100 + strlen(msg)];
00068        sprintf(msgString,"%s(%d) :%s\n",file,lineNumber,msg);
00069 
00070        ::OutputDebugStringA(msgString);
00071        
00072        delete [] msgString;
00073        SetLastError(lastError);
00074     }
00075 #else
00076 
00077 #endif