From d535d000d403110b6598253096b8226de1b6168a Mon Sep 17 00:00:00 2001 From: kelvinkuo Date: Thu, 25 Oct 2018 23:34:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=20assert=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a00527..946078e 100644 --- a/README.md +++ b/README.md @@ -230,10 +230,15 @@ int main() ### assert() -断言,是宏,而非函数。assert 宏的原型定义在``(C)、``(C++)中,其作用是如果它的条件返回错误,则终止程序执行。如: +断言,是宏,而非函数。assert 宏的原型定义在``(C)、``(C++)中,其作用是如果它的条件返回错误,则终止程序执行。可以通过定义`NDEBUG`来关闭assert,但是需要在源代码的开头,`include ` 之前。如: ```cpp assert( p != NULL ); + +#define NDEBUG +#include + +assert( p != NULL ); //disable assert ``` ### sizeof() @@ -3171,4 +3176,4 @@ int main( void ) ### Segmentfault -* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529) \ No newline at end of file +* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529)