diff options
| author | jackpoz <giacomopoz@gmail.com> | 2017-11-18 15:35:44 +0100 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2017-11-18 20:29:25 +0100 |
| commit | 7ef22e43057080926685eb45f0fce3f2f3d58c61 (patch) | |
| tree | c5a120b4a86112cdfe564110283a0a9cf7abc1bc /dep/recastnavigation/Recast/Include/RecastAssert.h | |
| parent | 64ca4717349fe3e418f1abe377f81be77818977c (diff) | |
Dep/Recast: Update recastnavigation to https://github.com/recastnavigation/recastnavigation/commit/2c85309280dbc9c82029e7ab16dfb01b9235c74e
Diffstat (limited to 'dep/recastnavigation/Recast/Include/RecastAssert.h')
| -rw-r--r-- | dep/recastnavigation/Recast/Include/RecastAssert.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/dep/recastnavigation/Recast/Include/RecastAssert.h b/dep/recastnavigation/Recast/Include/RecastAssert.h index 2aca0d9a14f..e7cc10e4961 100644 --- a/dep/recastnavigation/Recast/Include/RecastAssert.h +++ b/dep/recastnavigation/Recast/Include/RecastAssert.h @@ -23,11 +23,34 @@ // Feel free to change the file and include your own implementation instead. #ifdef NDEBUG + // From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ -# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false) +# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false) + #else + +/// An assertion failure function. +// @param[in] expression asserted expression. +// @param[in] file Filename of the failed assertion. +// @param[in] line Line number of the failed assertion. +/// @see rcAssertFailSetCustom +typedef void (rcAssertFailFunc)(const char* expression, const char* file, int line); + +/// Sets the base custom assertion failure function to be used by Recast. +/// @param[in] assertFailFunc The function to be used in case of failure of #dtAssert +void rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc); + +/// Gets the base custom assertion failure function to be used by Recast. +rcAssertFailFunc* rcAssertFailGetCustom(); + # include <assert.h> -# define rcAssert assert +# define rcAssert(expression) \ + { \ + rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \ + if(failFunc == NULL) { assert(expression); } \ + else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \ + } + #endif #endif // RECASTASSERT_H |
