Log assert messages

Now, assert messages as visible in the trace output
as well as the line number of condition that failed.
This commit is contained in:
Sam Clegg 2013-03-17 19:31:50 -07:00
parent e6afc9a180
commit e699919bc6
1 changed files with 8 additions and 5 deletions

View File

@ -37,11 +37,14 @@ THE SOFTWARE.
#ifndef CCAssert #ifndef CCAssert
#if COCOS2D_DEBUG > 0 #if COCOS2D_DEBUG > 0
extern void CC_DLL cc_assert_script_compatible(bool cond, const char *msg); extern void CC_DLL cc_assert_script_compatible(bool cond, const char *msg);
#define CCAssert(cond, msg) \ #define CCAssert(cond, msg) do { \
{ \ cc_assert_script_compatible(!!(cond), (msg)); \
cc_assert_script_compatible(!!(cond), (msg)); \ if (!(cond)) { \
CC_ASSERT(cond); \ if (strlen(msg)) \
} cocos2d::CCLog("Assert failed: %s", msg); \
CC_ASSERT(cond); \
} \
} while (0)
#else #else
#define CCAssert(cond, msg) #define CCAssert(cond, msg)
#endif #endif