Path: blob/master/thirdparty/recastnavigation/Recast/Include/RecastAssert.h
9913 views
//1// Copyright (c) 2009-2010 Mikko Mononen [email protected]2//3// This software is provided 'as-is', without any express or implied4// warranty. In no event will the authors be held liable for any damages5// arising from the use of this software.6// Permission is granted to anyone to use this software for any purpose,7// including commercial applications, and to alter it and redistribute it8// freely, subject to the following restrictions:9// 1. The origin of this software must not be misrepresented; you must not10// claim that you wrote the original software. If you use this software11// in a product, an acknowledgment in the product documentation would be12// appreciated but is not required.13// 2. Altered source versions must be plainly marked as such, and must not be14// misrepresented as being the original software.15// 3. This notice may not be removed or altered from any source distribution.16//1718#ifndef RECASTASSERT_H19#define RECASTASSERT_H2021#ifdef NDEBUG2223// From https://web.archive.org/web/20210117002833/http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/24# define rcAssert(x) do { (void)sizeof(x); } while ((void)(__LINE__==-1), false)2526#else2728/// An assertion failure function.29// @param[in] expression asserted expression.30// @param[in] file Filename of the failed assertion.31// @param[in] line Line number of the failed assertion.32/// @see rcAssertFailSetCustom33typedef void (rcAssertFailFunc)(const char* expression, const char* file, int line);3435/// Sets the base custom assertion failure function to be used by Recast.36/// @param[in] assertFailFunc The function to be used in case of failure of #dtAssert37void rcAssertFailSetCustom(rcAssertFailFunc* assertFailFunc);3839/// Gets the base custom assertion failure function to be used by Recast.40rcAssertFailFunc* rcAssertFailGetCustom();4142# include <assert.h>43# define rcAssert(expression) \44{ \45rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \46if (failFunc == NULL) { assert(expression); } \47else if (!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \48}4950#endif5152#endif // RECASTASSERT_H535455