Changeset 8372 for code/trunk/src/libraries/util
- Timestamp:
- May 1, 2011, 9:02:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/OrxAssert.h
r7401 r8372 40 40 41 41 #include <cassert> 42 #include " OutputHandler.h"42 #include "Debug.h" 43 43 44 44 #ifndef NDEBUG 45 45 46 /** Run time assertion like assert(), but with an embedded message. 46 47 @details … … 51 52 @endcode 52 53 */ 53 #define OrxAssert(Assertion, ErrorMessage) \ 54 Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \ 55 assert(Assertion) 54 #define OrxAssert(condition, errorMessage) \ 55 do \ 56 { \ 57 if (!(condition)) \ 58 { \ 59 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \ 60 COUT(1) << "Assertion failed in " << __FUNCTIONNAME__ << std::endl; \ 61 COUT(1) << "Expression: " << #condition << std::endl; \ 62 COUT(1) << "Message : " << errorMessage << std::endl; \ 63 /* Don't use the condition again to avoid double evaluation */ \ 64 /* Instead, stringify the expression and negate it */ \ 65 assert(!#condition); \ 66 } \ 67 } while (false) 68 69 /** Works like OrxAssert in debug mode, but also checks the condition in release 70 mode (no abort() triggered then). 71 @details 72 The message will be printed as error with COUT(1). <br> 73 You can use the same magic here as you can with \ref ThrowException 74 @code 75 OrxVerify(condition, "Text: " << number << " more text"); 76 @endcode 77 */ 78 #define OrxVerify(condition, errorMessage) \ 79 do \ 80 { \ 81 if (!(condition)) \ 82 { \ 83 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \ 84 COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \ 85 COUT(1) << "Expression: " << #condition << std::endl; \ 86 COUT(1) << "Message : " << errorMessage << std::endl; \ 87 /* Don't use the condition again to avoid double evaluation */ \ 88 /* Instead, stringify the expression and negate it */ \ 89 assert(!#condition); \ 90 } \ 91 } while (false) 92 56 93 #else 94 57 95 #define OrxAssert(condition, errorMessage) ((void)0) 96 97 #define OrxVerify(condition, errorMessage) \ 98 do \ 99 { \ 100 if (!(condition)) \ 101 { \ 102 COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \ 103 COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \ 104 COUT(1) << "Expression: " << #condition << std::endl; \ 105 COUT(1) << "Message : " << errorMessage << std::endl; \ 106 /* No assert() in release configuration */ \ 107 } \ 108 } while (false) 109 58 110 #endif 59 111
Note: See TracChangeset
for help on using the changeset viewer.