当前位置:操作系统 > 安卓/Android >>

去除使用log时的警告信息:"LOG_TAG" redefined 的方法

在Andorid源码开发模式下,当我们使用log时,一般会在头文件或文件开头处定义TAG_LOG宏 ,如下:
[cpp]
#define LOG_TAG "test" 

当编译时会出现如下警告:
[plain]
external/attest/attest.cpp:10:1: warning: "LOG_TAG" redefined 
In file included from external/attest/attest.cpp:5: 
system/core/include/cutils/log.h:68:1: warning: this is the location of the previous definition 

意思是LOG_TAG宏重定义,一般情况下,我们不理这个警告,但是如果你看着这个警告不爽,想除去而后快的话,那么该如何做呢?
其实很简单,如下操作即可:
[cpp]
#ifdef LOG_TAG 
#undef LOG_TAG 
#define LOG_TAG "test" 
#endif 

这样就避免宏LOG_TAG重定义了.


摘自 放飞梦想,成就未来
补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,