Skip to content

Commit

Permalink
Merge pull request huihut#20 from kelvinkuo/master
Browse files Browse the repository at this point in the history
补充 assert部分的内容
  • Loading branch information
huihut authored Oct 26, 2018
2 parents bdb541f + d535d00 commit 6cef0f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,15 @@ int main()

### assert()

断言,是宏,而非函数。assert 宏的原型定义在`<assert.h>`(C)、`<cassert>`(C++)中,其作用是如果它的条件返回错误,则终止程序执行。如:
断言,是宏,而非函数。assert 宏的原型定义在`<assert.h>`(C)、`<cassert>`(C++)中,其作用是如果它的条件返回错误,则终止程序执行。可以通过定义`NDEBUG`来关闭assert,但是需要在源代码的开头,`include <assert.h>` 之前。如:

```cpp
assert( p != NULL );

#define NDEBUG
#include <assert.h>

assert( p != NULL ); //disable assert
```
### sizeof()
Expand Down Expand Up @@ -3171,4 +3176,4 @@ int main( void )
### Segmentfault
* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529)
* [segmentfault . C++常见面试问题总结](https://segmentfault.com/a/1190000003745529)

0 comments on commit 6cef0f5

Please sign in to comment.