xcode -DNDEBUG 和 -DNS_BLOCK_ASSERTIONS 标志有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33691547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between -DNDEBUG and -DNS_BLOCK_ASSERTIONS flags
提问by Ossir
I've tried FauxPas
source code analyzer and it showed me that I am missing -DNDEBUG
flag, with next description:
我试过FauxPas
源代码分析器,它告诉我我缺少-DNDEBUG
标志,下一个描述:
This argument disables the C standard library assertion macro (as defined in assert.h).
此参数禁用 C 标准库断言宏(如 assert.h 中所定义)。
Though, when I check my build settings I found very similar by description flag -DNS_BLOCK_ASSERTIONS=1
.
但是,当我检查我的构建设置时,我发现 description flag 非常相似-DNS_BLOCK_ASSERTIONS=1
。
So I wonder now. Do I really need the flag that FauxPas
suggests or I am fine with the one I have?
所以我现在想知道。我真的需要FauxPas
建议的标志还是我对我拥有的标志很好?
回答by Rob Napier
NDEBUG
disables assert()
, which is part of the C standard library. NS_BLOCK_ASSERTIONS
disables NSAssert()
which is part of Foundation. You generally will require both if you have both kinds of assertions in your code.
NDEBUG
disables assert()
,它是 C 标准库的一部分。NS_BLOCK_ASSERTIONS
禁用NSAssert()
它是 Foundation 的一部分。如果您的代码中有两种断言,您通常会同时需要两者。