support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 3c8a3f259b
641 changed files with 10349 additions and 9523 deletions

View File

@@ -9,11 +9,11 @@
## 1.First assertion case
assert**is macrorather than function**。
Assert, **is macrorather than function**.
assert The prototype of a macro is defined in <assert.h>C<cassert>C++.If its condition returns an errorProgram execution is terminated.
Assert the prototype of a macro is defined in <assert.h>(C) or <cassert>(C++). If its condition is false or returns an error, program execution will terminate.
You can close assert by defining 'ndebug', **But it needs to be at the beginning of the source codebefore include <assert.h>.**
You can disable assert by defining macro `NDEBUG`, **But it needs to be at the beginning of the source codebefore include <assert.h>.**
```c
void assert(int expression);
@@ -49,11 +49,11 @@ assert: assert.c:13: main: Assertion 'x==7' failed.
+ Assertions are mainly used to check for logically impossible situations.
>For example, they can be used to check the state that code expects before it starts to run, or after the run is complete. Unlike normal error handling, assertions are usually disabled at run time.
> For example, they can be used to check the state that code expects before it starts to run, or after the run is complete. Unlike normal error handling, assertions are usually disabled at run time.
+ Ignore the assertion and add at the beginning of the code
```c++
#define NDEBUG // Adding this linethen you do not need the assert
#define NDEBUG // Adding this linethen assert will be disable
```
> Code Example[ignore_assert.c](./ignore_assert.c)

View File

@@ -1,12 +1,12 @@
/**
* @file ignore_assert.c
* @brief 忽略断言
* @author 光城
* @brief Ignore assertion
* @author Light-City
* @version v1
* @date 2019-07-25
*/
# define NDEBUG // 忽略断言
#define NDEBUG // ignore assertion
#include<assert.h>