android 中CHECK宏分析
来源:互联网 发布:什么是采集软件 编辑:程序博客网 时间:2024/04/30 02:59
看到CHECK宏,开始以为和ASSERT一样,在release中不起作用。实际上是起作用的,会引起退出。下面是具体的源代码分析
32 #define CHECK(condition) \ 33 LOG_ALWAYS_FATAL_IF( \ 34 !(condition), \ 35 "%s", \ 36 __FILE__ ":" LITERAL_TO_STRING(__LINE__) \ 37 " CHECK(" #condition ") failed.")302 /*303 * Log a fatal error. If the given condition fails, this stops program304 * execution like a normal assertion, but also generating the given message.305 * It is NOT stripped from release builds. Note that the condition test306 * is -inverted- from the normal assert() semantics.307 */308 #ifndef LOG_ALWAYS_FATAL_IF309 #define LOG_ALWAYS_FATAL_IF(cond, ...) \310 ( (CONDITION(cond)) \311 ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \312 : (void)0 )313 #endif470 #define android_printAssert(cond, tag, fmt...) \471 __android_log_assert(cond, tag, \472 __android_second(0, ## fmt, NULL) __android_rest(fmt))116 void __android_log_assert(const char *cond, const char *tag,117 const char *fmt, ...)118 #if defined(__GNUC__)119 __attribute__ ((noreturn))120 __attribute__ ((format(printf, 3, 4)))121 #endif122 ;223 void __android_log_assert(const char *cond, const char *tag,224 const char *fmt, ...)225 {226 char buf[LOG_BUF_SIZE];227228 if (fmt) {229 va_list ap;230 va_start(ap, fmt);231 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);232 va_end(ap);233 } else {234 /* Msg not provided, log condition. N.B. Do not use cond directly as235 * format string as it could contain spurious '%' syntax (e.g.236 * "%d" in "blocks%devs == 0").237 */238 if (cond)239 snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond);240 else241 strcpy(buf, "Unspecified assertion failed");242 }243244 __android_log_write(ANDROID_LOG_FATAL, tag, buf);245246 __builtin_trap(); /* trap so we have a chance to debug the situation */247 }
- android 中CHECK宏分析
- cpp check 分析
- check style 分析
- check android activity exist
- android check root
- check全选中/不中
- MySQL中check语句
- Oracle 中 check约束
- Android中Application分析
- Android中ANR分析
- Android中dispatchDraw分析
- android check symbols in so
- android 6.0 Runtime Permissions Check
- Android Studio check update失败
- android free mail check - MOP
- treeview中check复选事件
- C#中check和uncheck
- MySQL中CHECK约束无效
- Uva 10795 - A Different Task
- iOS基础面试题(一)
- K-L变换
- wchar_t TO char & char TO wchar_t
- iOS基础面试题(二)
- android 中CHECK宏分析
- 冒泡排序算法
- Asp.Net 中将多个RadioButton指定在一个组中
- 时空上下文视觉跟踪(STC)算法的解读与代码复现
- Form表单标签的Enctype属性
- iOS基础面试题(三)
- 类员函数的重载、覆盖和隐藏
- C++ const 总结
- iOS基础面试题(四)