Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Hirsch
crap
Commits
ea5c2b6f
Commit
ea5c2b6f
authored
Aug 29, 2019
by
Alexander Hirsch
Browse files
Add Assertions section
parent
4f0a1f91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
slides/c_slides.md
slides/c_slides.md
+22
-0
No files found.
slides/c_slides.md
View file @
ea5c2b6f
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment