1、宏介绍
_FILE_:当前源文件名,char字符,使用/FC选项产生全路径
_LINE_:当前源文件的行号,正数
_DATE_:当前编译日期,char字符串,格式:Aug 28 2011
_TIME_:当前编译时间,char字符串,格式:10:32:12
_FUNC_:当前函数
_FUNCTION_:当前函数
_TIMESTAMP_:最后一次修改当前文件的时间戳,char字符串,格式:Sun Aug 28 13:05:34 2014
2、宏使用
- // MacroTest.h
- void PrintSourceInfo()
- {
- const _TCHAR* pszstdc;
- const _TCHAR* pszcpp;
- #if __STDC__
- pszstdc = _T("YES");
- #else
- pszstdc = _T("NO");
- #endif
- #ifdef __cplusplus
- pszcpp = _T("YES");
- #else
- pszcpp = _T("NO");
- #endif
- _tprintf(_T("File: %s, Line: %d, Date: %s, Time: %s, Timestamp: %s, ANSI/ISO C: %s, C++: %s\n"),
- _T(__FILE__), __LINE__, _T(__DATE__), _T(__TIME__), _T(__TIMESTAMP__), pszstdc, pszcpp);
- }
- // 宏化的 PrintSourceInfo()
- #define PRINT_SOURCE_INFO() \
- _tprintf(_T("File: %s, Line: %d, Date: %s, Time: %s, Timestamp: %s\n"), \
- _T(__FILE__), __LINE__, _T(__DATE__), _T(__TIME__), _T(__TIMESTAMP__));
或者像这样
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "native-activity", __VA_ARGS__))
LOGE("%s: AttachCurrentThread() failed", __FUNCTION__);
转自:http://blog.youkuaiyun.com/yuxikuo_1/article/details/40458459