Xcode是否在调试版本中自动设置一个宏? [英] Is there a macro that Xcode automatically sets in debug builds?
本文介绍了Xcode是否在调试版本中自动设置一个宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我可以这样编写代码:
So I can write code like this:
#ifdef [whatever]
// do stuff that will never show up in the production version
#endif
推荐答案
p>如果您可以假设调试版本总是使用 gcc -O0
(通常情况下,但是有人可能会发生奇怪的异常,例如有人更改了调试版本的优化级别)然后你可以这样做:
If you can assume that debug builds always use gcc -O0
(this is normally the case, but there may be odd exceptions where someone has changed the optimisation level for debug builds) then you can do this:
#if __OPTIMIZE__
// ... non-debug stuff ...
#else
// ... debug stuff ...
#endif
这篇关于Xcode是否在调试版本中自动设置一个宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文