- Timestamp:
- May 19, 2015 11:20:24 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 100444
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VirtualBoxBase.h
r55944 r55945 156 156 * @param expr Expression which should be true. 157 157 */ 158 #if defined(DEBUG) 159 # define ComAssert(expr) Assert(expr) 160 #else 161 # define ComAssert(expr) \ 158 #define ComAssert(expr) \ 162 159 do { \ 163 160 if (RT_LIKELY(!!(expr))) \ 164 161 { /* likely */ } \ 165 162 else \ 163 { \ 164 AssertMsgFailed(("%s\n", #expr)); \ 166 165 setError(E_FAIL, \ 167 166 "Assertion failed: [%s] at '%s' (%d) in %s.\nPlease contact the product vendor!", \ 168 167 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ 169 } while (0)170 #endif 168 } \ 169 } while (0) 171 170 172 171 /** … … 181 180 * 182 181 */ 183 #if defined(DEBUG) 184 # define ComAssertFailed() AssertFailed() 185 #else 186 # define ComAssertFailed() \ 187 do { \ 182 #define ComAssertFailed() \ 183 do { \ 184 AssertFailed(); \ 188 185 setError(E_FAIL, \ 189 186 "Assertion failed: at '%s' (%d) in %s.\nPlease contact the product vendor!", \ 190 187 __FILE__, __LINE__, __PRETTY_FUNCTION__); \ 191 188 } while (0) 192 #endif193 189 194 190 /** … … 201 197 * @param a printf argument list (in parenthesis). 202 198 */ 203 #if defined(DEBUG) 204 # define ComAssertMsg(expr, a) AssertMsg(expr, a) 205 #else 206 # define ComAssertMsg(expr, a) \ 199 #define ComAssertMsg(expr, a) \ 207 200 do { \ 208 201 if (RT_LIKELY(!!(expr))) \ 209 202 { /* likely */ } \ 210 203 else \ 204 { \ 205 Utf8StrFmt MyAssertMsg a; /* may throw bad_alloc */ \ 206 AssertMsgFailed(("%s\n", MyAssertMsg.c_str())); \ 211 207 setError(E_FAIL, \ 212 208 "Assertion failed: [%s] at '%s' (%d) in %s.\n%s.\nPlease contact the product vendor!", \ 213 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__, Utf8StrFmt a.c_str()); \214 } while (0)215 #endif 209 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__, MyAssertMsg.c_str()); \ 210 } \ 211 } while (0) 216 212 217 213 /** … … 223 219 * @param a printf argument list (in parenthesis). 224 220 */ 225 #if defined(DEBUG) 226 # define ComAssertMsgFailed(a) AssertMsgFailed(a) 227 #else 228 # define ComAssertMsgFailed(a) \ 229 do { \ 221 #define ComAssertMsgFailed(a) \ 222 do { \ 223 Utf8StrFmt MyAssertMsg a; /* may throw bad_alloc */ \ 224 AssertMsgFailed(("%s\n", MyAssertMsg.c_str())); \ 230 225 setError(E_FAIL, \ 231 226 "Assertion failed: at '%s' (%d) in %s.\n%s.\nPlease contact the product vendor!", \ 232 __FILE__, __LINE__, __PRETTY_FUNCTION__, Utf8StrFmt a .c_str()); \ 233 } while (0) 234 #endif 227 __FILE__, __LINE__, __PRETTY_FUNCTION__, MyAssertMsg.c_str()); \ 228 } while (0) 235 229 236 230 /** … … 242 236 * @param vrc VBox status code. 243 237 */ 244 #if defined(DEBUG) 245 # define ComAssertRC(vrc) AssertRC(vrc) 246 #else 247 # define ComAssertRC(vrc) ComAssertMsgRC(vrc, ("%Rra", vrc)) 248 #endif 238 #define ComAssertRC(vrc) ComAssertMsgRC(vrc, ("%Rra", vrc)) 249 239 250 240 /** … … 257 247 * @param msg printf argument list (in parenthesis). 258 248 */ 259 #if defined(DEBUG) 260 # define ComAssertMsgRC(vrc, msg) AssertMsgRC(vrc, msg) 261 #else 262 # define ComAssertMsgRC(vrc, msg) ComAssertMsg(RT_SUCCESS(vrc), msg) 263 #endif 249 #define ComAssertMsgRC(vrc, msg) ComAssertMsg(RT_SUCCESS(vrc), msg) 264 250 265 251 /** … … 269 255 * See ComAssert for more info. 270 256 * 271 * @param rc COM result code 272 */ 273 #if defined(DEBUG) 274 # define ComAssertComRC(rc) AssertComRC(rc) 275 #else 276 # define ComAssertComRC(rc) ComAssertMsg(SUCCEEDED(rc), ("COM RC = %Rhrc (0x%08X)", (rc), (rc))) 277 #endif 257 * @param hrc COM result code 258 */ 259 #define ComAssertComRC(hrc) ComAssertMsg(SUCCEEDED(hrc), ("COM RC=%Rhrc (0x%08X)", (hrc), (hrc))) 278 260 279 261 … … 565 547 RTAssertDebugBreak(); \ 566 548 throw (a); \ 567 } while (0)549 } while (0) 568 550 #else 569 551 # define DebugBreakThrow(a) throw (a)
Note:
See TracChangeset
for help on using the changeset viewer.