补充 assert部分

This commit is contained in:
kelvinkuo 2018-10-25 23:34:23 +08:00 committed by GitHub
parent bdb541f9ae
commit d535d000d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()