Tuesday, September 4, 2012

Android NDK assert.h problems

Usually program will crash due to SIGSEGV signal after assert() is called, by default NDEBUG is define, you may turn off by add the flag (LOCAL_CFLAGS += -UNDEBUG) during compilation but not work for my case.

I found another solution is using __android_log_assert, simply define as below & replace assert() with assert3.

#define assert3(e) ((e) ? (void)0 : __android_log_assert(0,TAGS,"%s(%s:%d) >> %s ",__func__ ,__FILE__, __LINE__, #e))