From e699919bc63cf60a1dc92ec102e28129e6665699 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 17 Mar 2013 19:31:50 -0700 Subject: [PATCH] Log assert messages Now, assert messages as visible in the trace output as well as the line number of condition that failed. --- cocos2dx/include/ccMacros.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index dde93334e2..1d4eae699d 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -37,11 +37,14 @@ THE SOFTWARE. #ifndef CCAssert #if COCOS2D_DEBUG > 0 extern void CC_DLL cc_assert_script_compatible(bool cond, const char *msg); -#define CCAssert(cond, msg) \ - { \ - cc_assert_script_compatible(!!(cond), (msg)); \ - CC_ASSERT(cond); \ - } +#define CCAssert(cond, msg) do { \ + cc_assert_script_compatible(!!(cond), (msg)); \ + if (!(cond)) { \ + if (strlen(msg)) \ + cocos2d::CCLog("Assert failed: %s", msg); \ + CC_ASSERT(cond); \ + } \ + } while (0) #else #define CCAssert(cond, msg) #endif