在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重定義瞭.
摘自 放飛夢想,成就未來