【发布时间】:2011-09-20 09:05:54
【问题描述】:
当我构建项目以供发布时,我试图弄清楚如何从项目中去除调试日志记录,并在此处找到了一个出色的线程:Is it true that one should not use NSLog() on production code?
另一个用户解释了如何启用/禁用 DEBUG_MODE 定义的答案,所以我完全按照说明进行了操作,即
在项目设置“预处理器宏”中,调试行已读取“debug=1”,因此我将“debug_mode=1”添加到字符串末尾,使其现在读取“debug=1 debugmode= 1"(中间有一个 ${inherited},不管是什么......)
但是,我现在收到编译器黄色警告:
词法或预处理器问题,“DEBUG_MODE”宏在我添加的 prefix.pch 文件的行上重新定义:
#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif
如果有人能解释这个定义问题,我将不胜感激。
【问题讨论】:
标签: ios objective-c xcode c-preprocessor compiler-warnings