Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / CDTestFramework / Opcode / Ice / IceAssert.h
1 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 /**
3  *      Contains custom assertion code.
4  *      \file           IceAssert.h
5  *      \author         Pierre Terdiman
6  *      \date           January, 14, 2001
7  */
8 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
10 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 // Include Guard
12 #ifndef ICEASSERT_H
13 #define ICEASSERT_H
14
15 // Leave the {} so that you can write this kind of things safely in release mode:
16 //      if(condition)   ASSERT()
17
18 #ifndef ASSERT
19         #if defined( _DEBUG )
20                 FUNCTION ICECORE_API bool CustomAssertFunction(int, char*, int, char*, bool&);
21
22                 //! Custom ASSERT function. Various usages:
23                 //! ASSERT(condition)
24                 //! ASSERT(!"Not implemented")
25                 //! ASSERT(condition && "error text")
26                 #define ASSERT(exp)                                                                                                                                             \
27                 {                                                                                                                                                                               \
28                         static bool IgnoreAlways = false;                                                                                                       \
29                         if(!IgnoreAlways)                                                                                                                                       \
30                         {                                                                                                                                                                       \
31                                 if(CustomAssertFunction((int)(exp), #exp, __LINE__, __FILE__, IgnoreAlways))    \
32                                 {                                                                                                                                                               \
33                                         _asm { int 3 }                                                                                                                          \
34                                 }                                                                                                                                                               \
35                         }                                                                                                                                                                       \
36                 }
37         #else
38                 #define ASSERT(exp)     {}
39         #endif
40 #endif
41
42 #ifndef assert
43         #define assert  ASSERT
44 #endif
45
46         #define ICE_COMPILE_TIME_ASSERT(exp)    extern char ICE_Dummy[ (exp) ? 1 : -1 ]
47
48 #endif // ICEASSERT_H