版本

menu_open
Wwise SDK 2023.1.9
AkAssert.h
浏览该文件的文档.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Copyright (c) 2024 Audiokinetic Inc.
25 *******************************************************************************/
26 
27 #ifndef _AK_AKASSERT_H_
28 #define _AK_AKASSERT_H_
29 
30 #if defined( _DEBUG ) && !(defined AK_DISABLE_ASSERTS)
31  #ifndef AK_ENABLE_ASSERTS
32  #define AK_ENABLE_ASSERTS
33  #endif
34 #endif
35 
36 #ifdef AK_ENABLE_ASSERTS
38  #ifndef AK_ASSERT_HOOK
39  AK_CALLBACK( void, AkAssertHook)(
40  const char * in_pszExpression, ///< Expression
41  const char * in_pszFileName, ///< File Name
42  int in_lineNumber ///< Line Number
43  );
44  #define AK_ASSERT_HOOK
45  #endif
46 #endif
47 
48 #if !defined( AKASSERT )
49  #include <AK/SoundEngine/Common/AkTypes.h> //For AK_Fail/Success
50 
51  #if defined( AK_ENABLE_ASSERTS )
52  extern AKSOUNDENGINE_API AkAssertHook g_pAssertHook;
53 
54  // These platforms use a built-in g_pAssertHook (and do not fall back to the regular assert macro)
55  #define AKASSERT(Condition) ((Condition) ? ((void) 0) : g_pAssertHook( #Condition, __FILE__, __LINE__) )
56 
57  #define AKVERIFY AKASSERT
58 
59  #ifdef _DEBUG
60  #define AKASSERTD AKASSERT
61  #else
62  #define AKASSERTD(Condition) ((void)0)
63  #endif
64 
65  #else // defined( AK_ENABLE_ASSERTS )
66 
67  #define AKASSERT(Condition) do { switch ( 0 ) { case 0: break; default: if ( !( Condition ) ) {} } } while ( 0 )
68 
69  #define AKVERIFY(x) ((void)(x))
70 
71  #ifdef _DEBUG
72  #define AKASSERTD AKASSERT
73  #else
74  #define AKASSERTD(Condition) ((void)0)
75  #endif
76 
77  #endif // defined( AK_ENABLE_ASSERTS )
78 
79  #define AKASSERT_RANGE(Value, Min, Max) (AKASSERT(((Value) >= (Min)) && ((Value) <= (Max))))
80 
81  #define AKASSERTANDRETURN( __Expression, __ErrorCode )\
82  if (!(__Expression))\
83  {\
84  AKASSERT(__Expression);\
85  return __ErrorCode;\
86  }\
87 
88  #define AKASSERTPOINTERORFAIL( __Pointer ) AKASSERTANDRETURN( __Pointer != NULL, AK_Fail )
89  #define AKASSERTSUCCESSORRETURN( __akr ) AKASSERTANDRETURN( __akr == AK_Success, __akr )
90 
91  #define AKASSERTPOINTERORRETURN( __Pointer ) \
92  if ((__Pointer) == NULL)\
93  {\
94  AKASSERT((__Pointer) == NULL);\
95  return ;\
96  }\
97 
98  #if defined( AK_WIN ) && ( _MSC_VER >= 1600 )
99  // Compile-time assert
100  #define AKSTATICASSERT( __expr__, __msg__ ) static_assert( (__expr__), (__msg__) )
101  #else
102  // Compile-time assert
103  #define AKSTATICASSERT( __expr__, __msg__ ) typedef char __AKSTATICASSERT__[(__expr__)?1:-1]
104  #endif
105 
106 #endif // ! defined( AKASSERT )
107 
108 #ifdef AK_ENABLE_ASSERTS
109 
110 
111 //Do nothing. This is a dummy function, so that g_pAssertHook is never NULL.
112 #define DEFINEDUMMYASSERTHOOK void AkAssertHookFunc( \
113 const char* in_pszExpression,\
114 const char* in_pszFileName,\
115 int in_lineNumber)\
116 {\
117 \
118 }\
119 AkAssertHook g_pAssertHook = AkAssertHookFunc;
120 #else
121 #define DEFINEDUMMYASSERTHOOK
122 
123 #endif
124 
125 // Compile-time assert. Usage:
126 // AkStaticAssert<[your boolean expression here]>::Assert();
127 // Example:
128 // AkStaticAssert<sizeof(MyStruct) == 20>::Assert(); //If you hit this, you changed the size of MyStruct!
129 // Empty default template
130 template <bool b>
131 struct AkStaticAssert {};
132 
133 // Template specialized on true
134 template <>
135 struct AkStaticAssert<true>
136 {
137  static void Assert() {}
138 };
139 
140 #endif
141 
static void Assert()
Definition: AkAssert.h:137
#define AKSOUNDENGINE_API
#define AK_CALLBACK(_type, _name)
void(* AkAssertHook)(const char *in_pszExpression, const char *in_pszFileName, int in_lineNumber)

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅