1*c2c66affSColin Finck // 2*c2c66affSColin Finck // assert.h 3*c2c66affSColin Finck // 4*c2c66affSColin Finck 5*c2c66affSColin Finck #ifndef __ASSERT_H 6*c2c66affSColin Finck #define __ASSERT_H 7*c2c66affSColin Finck 8*c2c66affSColin Finck #ifndef _MFC_VER 9*c2c66affSColin Finck #ifdef _WIN32_WCE 10*c2c66affSColin Finck 11*c2c66affSColin Finck #else//_WIN32_WCE 12*c2c66affSColin Finck #include <assert.h> 13*c2c66affSColin Finck #endif//_WIN32_WCE 14*c2c66affSColin Finck #endif 15*c2c66affSColin Finck 16*c2c66affSColin Finck #ifndef ASSERT 17*c2c66affSColin Finck #ifdef _DEBUG 18*c2c66affSColin Finck #include <crtdbg.h> 19*c2c66affSColin Finck #include <stdio.h> // _snprintf 20*c2c66affSColin Finck //#ifndef WINVER 21*c2c66affSColin Finck #ifdef _CONSOLE 22*c2c66affSColin Finck #define ASSERT(x) if(!(x)){printf("ASSERT FAILURE: (%s) at %s:%i\n", #x, __FILE__, __LINE__); _CrtDbgBreak(); } 23*c2c66affSColin Finck #else//_CONSOLE/WINVER 24*c2c66affSColin Finck #define ASSERT(x) if(!(x)){char stmp_assert[1024+1]; _snprintf(stmp_assert,1024,"ASSERT FAILURE: (%s) at %s:%i\n",#x,__FILE__,__LINE__); ::MessageBox(NULL,stmp_assert,"Assertion Failure",MB_OK|MB_ICONSTOP); _CrtDbgBreak(); } 25*c2c66affSColin Finck #endif//_CONSOLE/WINVER 26*c2c66affSColin Finck #else//_DEBUG 27*c2c66affSColin Finck #define ASSERT(x) 28*c2c66affSColin Finck #endif//_DEBUG 29*c2c66affSColin Finck #endif//ASSERT 30*c2c66affSColin Finck 31*c2c66affSColin Finck #undef VERIFY 32*c2c66affSColin Finck #ifdef _DEBUG 33*c2c66affSColin Finck #define VERIFY(x) ASSERT(x) 34*c2c66affSColin Finck #else//_DEBUG 35*c2c66affSColin Finck #define VERIFY(x) x 36*c2c66affSColin Finck #endif//_DEBUG 37*c2c66affSColin Finck 38*c2c66affSColin Finck // code for ASSERTing in Release mode... 39*c2c66affSColin Finck #ifdef RELEASE_ASSERT 40*c2c66affSColin Finck #undef ASSERT 41*c2c66affSColin Finck #include <stdio.h> 42*c2c66affSColin Finck #define ASSERT(x) if ( !(x) ) { char s[1024+1]; _snprintf(s,1024,"ASSERTION FAILURE:\n%s\n\n%s: line %i", #x, __FILE__, __LINE__ ); ::MessageBox(NULL,s,"Assertion Failure",MB_OK|MB_ICONERROR); } 43*c2c66affSColin Finck #undef VERIFY 44*c2c66affSColin Finck #define VERIFY ASSERT 45*c2c66affSColin Finck #endif//RELEASE_ASSERT 46*c2c66affSColin Finck 47*c2c66affSColin Finck #endif//__ASSERT_H 48