Changeset 37 in kStuff
- Timestamp:
- Nov 10, 2009 12:01:22 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/k/kHlpAssert.h
r29 r37 67 67 } while (0) 68 68 69 # define kHlpAssert(expr, stmt) \ 70 do { \ 71 if (!(expr)) \ 72 { \ 73 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 74 kHlpAssertBreakpoint(); \ 75 stmt; \ 76 } \ 77 } while (0) 78 69 79 # define kHlpAssertReturn(expr, rcRet) \ 70 80 do { \ … … 77 87 } while (0) 78 88 89 # define kHlpAssertStmtReturn(expr, stmt, rcRet) \ 90 do { \ 91 if (!(expr)) \ 92 { \ 93 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 94 kHlpAssertBreakpoint(); \ 95 stmt; \ 96 return (rcRet); \ 97 } \ 98 } while (0) 99 79 100 # define kHlpAssertReturnVoid(expr) \ 80 101 do { \ … … 87 108 } while (0) 88 109 110 # define kHlpAssertStmtReturnVoid(expr, stmt) \ 111 do { \ 112 if (!(expr)) \ 113 { \ 114 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 115 kHlpAssertBreakpoint(); \ 116 stmt; \ 117 return; \ 118 } \ 119 } while (0) 120 89 121 # define kHlpAssertMsg(expr, msg) \ 90 122 do { \ … … 97 129 } while (0) 98 130 131 # define kHlpAssertMsgStmt(expr, msg, stmt) \ 132 do { \ 133 if (!(expr)) \ 134 { \ 135 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 136 kHlpAssertMsg2 msg; \ 137 kHlpAssertBreakpoint(); \ 138 stmt; \ 139 } \ 140 } while (0) 141 99 142 # define kHlpAssertMsgReturn(expr, msg, rcRet) \ 100 143 do { \ … … 108 151 } while (0) 109 152 153 # define kHlpAssertMsgReturn(expr, msg, stmt, rcRet) \ 154 do { \ 155 if (!(expr)) \ 156 { \ 157 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 158 kHlpAssertMsg2 msg; \ 159 kHlpAssertBreakpoint(); \ 160 stmt; \ 161 return (rcRet); \ 162 } \ 163 } while (0) 164 110 165 # define kHlpAssertMsgReturnVoid(expr, msg) \ 111 166 do { \ … … 119 174 } while (0) 120 175 176 # define kHlpAssertMsgReturnVoid(expr, msg, stmt) \ 177 do { \ 178 if (!(expr)) \ 179 { \ 180 kHlpAssertMsg1(#expr, __FILE__, __LINE__, __FUNCTION__); \ 181 kHlpAssertMsg2 msg; \ 182 kHlpAssertBreakpoint(); \ 183 stmt; \ 184 return; \ 185 } \ 186 } while (0) 187 121 188 #else /* !K_STRICT */ 122 # define kHlpAssert(expr) do { } while (0) 123 # define kHlpAssertReturn(expr, rcRet) do { if (!(expr)) return (rcRet); } while (0) 124 # define kHlpAssertReturnVoid(expr) do { if (!(expr)) return; } while (0) 125 # define kHlpAssertMsg(expr, msg) do { } while (0) 126 # define kHlpAssertMsgReturn(expr, msg, rcRet) do { if (!(expr)) return (rcRet); } while (0) 127 # define kHlpAssertMsgReturnVoid(expr, msg) do { if (!(expr)) return; } while (0) 189 # define kHlpAssert(expr) do { } while (0) 190 # define kHlpAssertStmt(expr, stmt) do { if (!(expr)) { stmt; } } while (0) 191 # define kHlpAssertReturn(expr, rcRet) do { if (!(expr)) return (rcRet); } while (0) 192 # define kHlpAssertStmtReturn(expr, stmt, rcRet) do { if (!(expr)) { stmt; return (rcRet); } } while (0) 193 # define kHlpAssertReturnVoid(expr) do { if (!(expr)) return; } while (0) 194 # define kHlpAssertStmtReturnVoid(expr, stmt) do { if (!(expr)) { stmt; return; } } while (0) 195 # define kHlpAssertMsg(expr, msg) do { } while (0) 196 # define kHlpAssertMsgStmt(expr, msg, stmt) do { if (!(expr)) { stmt; } } while (0) 197 # define kHlpAssertMsgReturn(expr, msg, rcRet) do { if (!(expr)) return (rcRet); } while (0) 198 # define kHlpAssertMsgStmtReturn(expr, msg, stmt, rcRet) do { if (!(expr)) { stmt; return (rcRet); } } while (0) 199 # define kHlpAssertMsgReturnVoid(expr, msg) do { if (!(expr)) return; } while (0) 200 # define kHlpAssertMsgStmtReturnVoid(expr, msg, stmt) do { if (!(expr)) { stmt; return; } } while (0) 128 201 #endif /* !K_STRICT */ 129 202 130 203 #define kHlpAssertPtr(ptr) kHlpAssertMsg(K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr))) 204 #define kHlpAssertPtrReturn(ptr, rcRet) kHlpAssertMsgReturn(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet)) 131 205 #define kHlpAssertPtrReturn(ptr, rcRet) kHlpAssertMsgReturn(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet)) 132 206 #define kHlpAssertPtrReturnVoid(ptr) kHlpAssertMsgReturnVoid(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)))
Note:
See TracChangeset
for help on using the changeset viewer.