尝试将 #define DEBUG_MODE 添加到我的 prefix.pch 文件时出现编译器警告
我试图弄清楚如何在构建要发布的项目时从项目中删除调试日志记录,并在这里找到了一个出色的线程: 人们不应该在生产代码上使用 NSLog() 是真的吗?
比另一个答案稍低一点用户解释了如何启用/禁用 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
如果有人可以解释这个定义问题,我将不胜感激。
I'm trying to figure out how to strip debug logging from my project when I build it for release and found an excellent thread here: Is it true that one should not use NSLog() on production code?
A bit below the answer another user explained how to enable/disable the DEBUG_MODE definition, so I went in exactly as explained, i.e.
In the project settings, "preprocessor macros", debug row it already read "debug=1", so I added the "debug_mode=1" to the end of the string so that it now reads "debug=1 debugmode=1" (with an ${inherited} inbetween, whatever that is...)
However, I now get a compiler yellow warning saying:
Lexical or preprocessor issue, "DEBUG_MODE" macro redefined on the row in my prefix.pch file where I added:
#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
If someone could explain this define issue i'd be grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将其更改为:
从“预处理器宏”中删除
#define DEBUG_MODE
并删除debugmode=1
现在就可以走了。
您收到的错误是由于“预处理器宏”中已定义的
#define DEBUG_MODE
造成的。Just change it to:
Remove the
#define DEBUG_MODE
and remove thedebugmode=1
from the "preprocessor macros"and you are good to go.
The error you where getting was due to the
#define DEBUG_MODE
which was already defined in the "preprocessor macros".