AudRecordLib
macroutils.h
Go to the documentation of this file.
00001 
00006 #ifndef WINLIB_MACROUTILS_H
00007 #define WINLIB_MACROUTILS_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 
00056 #define DISABLE_CONST_COND() \
00057         __pragma(warning(push)) \
00058         __pragma(warning(disable : 4127))
00059 
00065 #define END_DISABLE_CONST_COND() \
00066         __pragma(warning(pop))
00067 
00068 #pragma endregion
00069 
00075 #define CASSERT(expr) \
00076         static const char CONCAT(cassertTester, __COUNTER__) [(expr) ? 1 : -1]
00077 
00078 #if defined(DEBUG) || defined(_DEBUG) || defined(_DBG)
00079 
00080 #ifdef _MSC_VER 
00081 __if_not_exists(OutputDebugStringA)
00082 {
00083         // so we don't have to include the windows header files
00084         extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char*);
00085         extern "C" __declspec(dllimport) void __stdcall DebugBreak();
00086 }
00087 #endif
00088 
00094 #define ASSERT(expr) \
00095         DISABLE_CONST_COND() \
00096         do \
00097         { \
00098                 if(!(expr)) \
00099                 { \
00100                         OutputDebugStringA( \
00101                         "Assertion Failed: " \
00102                         #expr \
00103                         "\nFile: " \
00104                         __FILE__ \
00105                         ", line " \
00106                         STRINGIFY(__LINE__) \
00107                         ", function \"" \
00108                         __FUNCTION__ \
00109                         "\".\n" \
00110                         ); \
00111                         DebugBreak(); \
00112                 } \
00113         } \
00114         while(0); \
00115         END_DISABLE_CONST_COND()        
00116 
00117 #else
00118 
00124 #define ASSERT(expr)
00125 
00126 #endif
00127 
00130 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Defines