Commit ea5c2b6f authored by Alexander Hirsch's avatar Alexander Hirsch
Browse files

Add Assertions section

parent 4f0a1f91
......@@ -324,6 +324,28 @@ void fun(int arr[10])
- Alternative use `snprintf`
- Always prefer bounds checking functions (e.g. `strncpy`) over their naïve variants (e.g. `strcpy`)
## Assertions
```c
struct expression *expression_binary_op(enumbinary_op op,
struct expression *lhs,
struct expression *rhs)
{
assert(lhs);
assert(rhs);
// …
}
```
---
- Make good use of `assert`!
- Commonly used to check pre-conditions
- Typically disabled in *release* builds
- No substitution for regular error checking!
- Assertions are meant to catch programmer errors
## Multiple Source Files
- Header-files define types and declare functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment