AudRecordLib
|
00001 00006 #ifndef WINLIB_SIMPLE_ASSERT_H 00007 #define WINLIB_SIMPLE_ASSERT_H 00008 00009 #pragma once 00010 00011 #pragma region support macros 00012 00016 #define CONCAT_INT(a, b) a##b 00017 00022 #define CONCAT(a, b) CONCAT_INT(a, b) 00023 00029 #define WSTRINGIFY_INT(a) CONCAT(L, #a) 00030 00036 #define WSTRINGIFY(a) WSTRINGIFY_INT(a) 00037 00041 #define STRINGIFY_INT(a) #a 00042 00048 #define STRINGIFY(a) STRINGIFY_INT(a) 00049 #pragma endregion 00050 00056 #define CASSERT(expr) \ 00057 static const char CONCAT(cassertTester, __COUNTER__) [(expr) ? 1 : -1] 00058 00059 #if defined(DEBUG) || defined(_DEBUG) || defined(_DBG) 00060 #ifdef _MSC_VER 00061 __if_not_exists(OutputDebugStringA) 00062 { 00063 // so we don't have to include the windows header files 00064 extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char*); 00065 extern "C" __declspec(dllimport) void __stdcall DebugBreak(); 00066 } 00067 #endif 00068 00074 #define ASSERT(expr) \ 00075 do \ 00076 { \ 00077 if(!(expr)) \ 00078 { \ 00079 OutputDebugStringA( \ 00080 "Assertion Failed: " \ 00081 #expr \ 00082 "\nFile: " \ 00083 __FILE__ \ 00084 ", line " \ 00085 STRINGIFY(__LINE__) \ 00086 ", function \"" \ 00087 __FUNCTION__ \ 00088 "\".\n" \ 00089 ); \ 00090 DebugBreak(); \ 00091 } \ 00092 } \ 00093 __pragma(warning(push)) \ 00094 __pragma(warning(disable : 4127)) \ 00095 while(0) \ 00096 __pragma(warning(pop)) 00097 00098 #else 00099 00100 #define ASSERT(expr) 00101 00102 #endif 00103 00106 #endif