バージョン
00001 /******************************************************************************* 00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology 00003 released in source code form as part of the SDK installer package. 00004 00005 Commercial License Usage 00006 00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology 00008 may use this file in accordance with the end user license agreement provided 00009 with the software or, alternatively, in accordance with the terms contained in a 00010 written agreement between you and Audiokinetic Inc. 00011 00012 Apache License Usage 00013 00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 00015 "Apache License"); you may not use this file except in compliance with the 00016 Apache License. You may obtain a copy of the Apache License at 00017 http://www.apache.org/licenses/LICENSE-2.0. 00018 00019 Unless required by applicable law or agreed to in writing, software distributed 00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for 00022 the specific language governing permissions and limitations under the License. 00023 00024 Version: <VERSION> Build: <BUILDNUMBER> 00025 Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc. 00026 *******************************************************************************/ 00027 00028 #ifndef _AK_AKASSERT_H_ 00029 #define _AK_AKASSERT_H_ 00030 00031 #if defined( _DEBUG ) && !(defined AK_DISABLE_ASSERTS) 00032 #ifndef AK_ENABLE_ASSERTS 00033 #define AK_ENABLE_ASSERTS 00034 #endif 00035 #endif 00036 00037 #if !defined( AKASSERT ) 00038 00039 #include <AK/SoundEngine/Common/AkTypes.h> //For AK_Fail/Success 00040 #include <AK/SoundEngine/Common/AkSoundEngineExport.h> 00041 00042 #if defined( AK_ENABLE_ASSERTS ) 00043 00044 #if defined( __SPU__ ) 00045 00046 #if defined ( _DEBUG ) 00047 // Note: No assert hook on SPU 00048 #include "spu_printf.h" 00049 #include "libsn_spu.h" 00050 #define AKASSERT(Condition) \ 00051 if ( !(Condition) ) \ 00052 { \ 00053 spu_printf( "Assertion triggered in file %s at line %d\n", __FILE__, __LINE__ );\ 00054 /*snPause();*/ \ 00055 } 00056 #else 00057 #define AKASSERT(Condition) 00058 #endif 00059 00060 #else // defined( __SPU__ ) 00061 00062 #ifndef AK_ASSERT_HOOK 00063 AK_CALLBACK( void, AkAssertHook)( 00064 const char * in_pszExpression, 00065 const char * in_pszFileName, 00066 int in_lineNumber 00067 ); 00068 #define AK_ASSERT_HOOK 00069 #endif 00070 00071 extern AKSOUNDENGINE_API AkAssertHook g_pAssertHook; 00072 00073 // These platforms use a built-in g_pAssertHook (and do not fall back to the regular assert macro) 00074 #define AKASSERT(Condition) ((Condition) ? ((void) 0) : g_pAssertHook( #Condition, __FILE__, __LINE__) ) 00075 00076 00077 #endif // defined( __SPU__ ) 00078 00079 #define AKVERIFY AKASSERT 00080 00081 #ifdef _DEBUG 00082 #define AKASSERTD AKASSERT 00083 #else 00084 #define AKASSERTD(Condition) ((void)0) 00085 #endif 00086 00087 #else // defined( AK_ENABLE_ASSERTS ) 00088 00089 #define AKASSERT(Condition) ((void)0) 00090 #define AKASSERTD(Condition) ((void)0) 00091 #define AKVERIFY(x) ((void)(x)) 00092 00093 #endif // defined( AK_ENABLE_ASSERTS ) 00094 00095 #define AKASSERT_RANGE(Value, Min, Max) (AKASSERT(((Value) >= (Min)) && ((Value) <= (Max)))) 00096 00097 #define AKASSERTANDRETURN( __Expression, __ErrorCode )\ 00098 if (!(__Expression))\ 00099 {\ 00100 AKASSERT(__Expression);\ 00101 return __ErrorCode;\ 00102 }\ 00103 00104 #define AKASSERTPOINTERORFAIL( __Pointer ) AKASSERTANDRETURN( __Pointer != NULL, AK_Fail ) 00105 #define AKASSERTSUCCESSORRETURN( __akr ) AKASSERTANDRETURN( __akr == AK_Success, __akr ) 00106 00107 #define AKASSERTPOINTERORRETURN( __Pointer ) \ 00108 if ((__Pointer) == NULL)\ 00109 {\ 00110 AKASSERT((__Pointer) == NULL);\ 00111 return ;\ 00112 }\ 00113 00114 #if defined( AK_WIN ) && ( _MSC_VER >= 1600 ) 00115 // Compile-time assert 00116 #define AKSTATICASSERT( __expr__, __msg__ ) static_assert( (__expr__), (__msg__) ) 00117 #else 00118 // Compile-time assert 00119 #define AKSTATICASSERT( __expr__, __msg__ ) typedef char __AKSTATICASSERT__[(__expr__)?1:-1] 00120 #endif 00121 00122 #endif // ! defined( AKASSERT ) 00123 00124 #ifdef AK_ENABLE_ASSERTS 00125 00126 00127 //Do nothing. This is a dummy function, so that g_pAssertHook is never NULL. 00128 #define DEFINEDUMMYASSERTHOOK void AkAssertHookFunc( \ 00129 const char* in_pszExpression,\ 00130 const char* in_pszFileName,\ 00131 int in_lineNumber)\ 00132 {\ 00133 \ 00134 }\ 00135 AkAssertHook g_pAssertHook = AkAssertHookFunc; 00136 #else 00137 #define DEFINEDUMMYASSERTHOOK 00138 00139 #endif 00140 00141 // Compile-time assert. Usage: 00142 // AkStaticAssert<[your boolean expression here]>::Assert(); 00143 // Example: 00144 // AkStaticAssert<sizeof(MyStruct) == 20>::Assert(); //If you hit this, you changed the size of MyStruct! 00145 // Empty default template 00146 template <bool b> 00147 struct AkStaticAssert {}; 00148 00149 // Template specialized on true 00150 template <> 00151 struct AkStaticAssert<true> 00152 { 00153 static void Assert() {} 00154 }; 00155 00156 #endif 00157