1 2 /* 3 This is our assert file for the Win95 4 platform, with Dave's global/local assert 5 distinctions. 6 */ 7 8 /* 9 Note that WaitForReturn now calls FlushTextprintBuffer 10 and FlipBuffers implicitly. 11 */ 12 13 /* 14 Modified 10th December 1996 by Dave Malcolm. Now can be set so that 15 functions are supplied by the project/platform to fire when an assertion 16 fires. 17 18 Also is set so that the compiler will generate an error message if you manage to 19 include the file more than once (with confusing definitons of UseLocalAssert); 20 this can be disabled. 21 */ 22 23 24 #ifdef _OURASERT 25 #if StopCompilationOnMultipleInclusions 26 #error OURASERT.H included more than once 27 #endif 28 #else 29 #define _OURASERT 1 30 #endif 31 32 33 #ifdef AVP_DEBUG_VERSION 34 #define ASSERT_SYSTEM_ON 1 35 #else 36 #define ASSERT_SYSTEM_ON 0 37 #endif 38 39 40 #if UseProjPlatAssert 41 /* New assertions system */ 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 int GlobalAssertFired(char* Filename, int LineNum, char* Condition); 47 int LocalAssertFired(char* Filename, int LineNum, char* Condition); 48 void ExitFired(char* Filename, int LineNum, int ExitCode); 49 #ifdef __cplusplus 50 }; 51 #endif 52 53 54 #if ASSERT_SYSTEM_ON 55 56 #define GLOBALASSERT(x) \ 57 (void)( (x) ? 1 : \ 58 ( \ 59 GlobalAssertFired \ 60 ( \ 61 __FILE__, \ 62 __LINE__, \ 63 #x \ 64 ) \ 65 ) \ 66 ) 67 68 #if UseLocalAssert 69 70 #define LOCALASSERT(x) \ 71 (void)( (x) ? 1 : \ 72 ( \ 73 LocalAssertFired \ 74 ( \ 75 __FILE__, \ 76 __LINE__, \ 77 #x \ 78 ) \ 79 ) \ 80 ) 81 82 #else 83 84 #define LOCALASSERT(ignore) 85 86 #endif 87 88 89 #define exit(x) ExitFired(__FILE__,__LINE__,x) 90 91 #else 92 93 #define GLOBALASSERT(ignore) ((void)0) 94 95 #define LOCALASSERT(ignore) ((void)0) 96 97 #endif 98 99 100 #else 101 /* Old assertions system */ 102 103 #define GlobalAssertCode 0xffff 104 #define LocalAssertCode 0xfffe 105 106 107 #if 0//debug 108 109 #define GLOBALASSERT(x) \ 110 (void)((x) ? 1 : \ 111 (textprint("\nGAF " #x "\nLINE %d\nFILE'%s'\n", \ 112 __LINE__, __FILE__), WaitForReturn(), \ 113 ExitSystem(), exit(GlobalAssertCode), \ 114 0)) 115 116 #if UseLocalAssert 117 118 #define LOCALASSERT(x) \ 119 (void)((x) ? 1 : \ 120 (textprint("\nLAF " #x "LINE %d\nFILE'%s'\n", \ 121 __LINE__, __FILE__), WaitForReturn(), \ 122 ExitSystem(), exit(LocalAssertCode), \ 123 0)) 124 125 #else 126 127 #define LOCALASSERT(ignore) 128 129 #endif 130 131 #else 132 133 #define GLOBALASSERT(ignore) 134 135 #define LOCALASSERT(ignore) 136 137 #endif 138 #endif 139