123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #ifndef _AK_AKASSERT_H_
- #define _AK_AKASSERT_H_
- #if defined( _DEBUG ) && !(defined AK_DISABLE_ASSERTS)
- #ifndef AK_ENABLE_ASSERTS
- #define AK_ENABLE_ASSERTS
- #endif
- #endif
- #ifdef AK_ENABLE_ASSERTS
- #include <AK/SoundEngine/Common/AkSoundEngineExport.h>
- #ifndef AK_ASSERT_HOOK
- AK_CALLBACK( void, AkAssertHook)(
- const char * in_pszExpression,
- const char * in_pszFileName,
- int in_lineNumber
- );
- #define AK_ASSERT_HOOK
- #endif
- #endif
- #if !defined( AKASSERT )
- #include <AK/SoundEngine/Common/AkTypes.h> //For AK_Fail/Success
- #if defined( AK_ENABLE_ASSERTS )
- extern AKSOUNDENGINE_API AkAssertHook g_pAssertHook;
-
- #define AKASSERT(Condition) ((Condition) ? ((void) 0) : g_pAssertHook( #Condition, __FILE__, __LINE__) )
- #define AKVERIFY AKASSERT
- #ifdef _DEBUG
- #define AKASSERTD AKASSERT
- #else
- #define AKASSERTD(Condition) ((void)0)
- #endif
- #else
- #define AKASSERT(Condition) do { switch ( 0 ) { case 0: break; default: if ( !( Condition ) ) {} } } while ( 0 )
- #define AKVERIFY(x) ((void)(x))
- #ifdef _DEBUG
- #define AKASSERTD AKASSERT
- #else
- #define AKASSERTD(Condition) ((void)0)
- #endif
- #endif
- #define AKASSERT_RANGE(Value, Min, Max) (AKASSERT(((Value) >= (Min)) && ((Value) <= (Max))))
- #define AKASSERTANDRETURN( __Expression, __ErrorCode )\
- if (!(__Expression))\
- {\
- AKASSERT(__Expression);\
- return __ErrorCode;\
- }\
- #define AKASSERTPOINTERORFAIL( __Pointer ) AKASSERTANDRETURN( __Pointer != NULL, AK_Fail )
- #define AKASSERTSUCCESSORRETURN( __akr ) AKASSERTANDRETURN( __akr == AK_Success, __akr )
- #define AKASSERTPOINTERORRETURN( __Pointer ) \
- if ((__Pointer) == NULL)\
- {\
- AKASSERT((__Pointer) == NULL);\
- return ;\
- }\
- #if defined( AK_WIN ) && ( _MSC_VER >= 1600 )
-
- #define AKSTATICASSERT( __expr__, __msg__ ) static_assert( (__expr__), (__msg__) )
- #else
-
- #define AKSTATICASSERT( __expr__, __msg__ ) typedef char __AKSTATICASSERT__[(__expr__)?1:-1]
- #endif
- #endif
- #ifdef AK_ENABLE_ASSERTS
- #define DEFINEDUMMYASSERTHOOK void AkAssertHookFunc( \
- const char* in_pszExpression,\
- const char* in_pszFileName,\
- int in_lineNumber)\
- {\
- \
- }\
- AkAssertHook g_pAssertHook = AkAssertHookFunc;
- #else
- #define DEFINEDUMMYASSERTHOOK
- #endif
- template <bool b>
- struct AkStaticAssert {};
- template <>
- struct AkStaticAssert<true>
- {
- static void Assert() {}
- };
- #endif
|