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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:12:00  来源:igfitidea点击:

What is the difference between -DNDEBUG and -DNS_BLOCK_ASSERTIONS flags

objective-cxcodebuild-settings

提问by Ossir

I've tried FauxPassource code analyzer and it showed me that I am missing -DNDEBUGflag, 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 FauxPassuggests or I am fine with the one I have?

所以我现在想知道。我真的需要FauxPas建议的标志还是我对我拥有的标志很好?

回答by Rob Napier

NDEBUGdisables assert(), which is part of the C standard library. NS_BLOCK_ASSERTIONSdisables NSAssert()which is part of Foundation. You generally will require both if you have both kinds of assertions in your code.

NDEBUGdisables assert(),它是 C 标准库的一部分。NS_BLOCK_ASSERTIONS禁用NSAssert()它是 Foundation 的一部分。如果您的代码中有两种断言,您通常会同时需要两者。