On this page
<math.h>, <time.h> & <assert.h>
Prev: stdint, stdbool & limits | Up: stdlib | Next: compilation_and_internals
Rel: Error Handling & goto cleanup
Ref: cppreference — assert
Tags: #public #prog #c #stdlib
Contents
Runtime assert & Compile-Time _Static_assert
assert(expr)aborts with file/line diagnostics in debug builds (compiled out when-DNDEBUGis defined — never put side effects insideassert()!)._Static_assert(expr, "msg")(C11,static_assertin C23) verifies struct sizes, alignments, and assumptions at compile time:
#include <assert.h>
#include <stdint.h>
_Static_assert(sizeof(uint32_t) == 4, "Expected 32-bit uint32_t");
<math.h> & <time.h>
- Link with
-lmon Linux when using<math.h>(sqrt,fabs,isfinite,isnan). - Use
timespec_get(&ts, TIME_UTC)(C11) for portable nanosecond wall-clock timestamps, orclock()for CPU time.
Linked from
- tuts/c/stdlib
- tuts/c/stdlib/assert
- tuts/c/stdlib/assert/assert
- tuts/c/stdlib/math
- tuts/c/stdlib/math/floor
- tuts/c/stdlib/math/isnan
- tuts/c/stdlib/math/pow
- tuts/c/stdlib/math/sqrt
- tuts/c/stdlib/math_time_and_assert
- tuts/c/stdlib/stdint_stdbool_and_limits
- tuts/c/stdlib/time
- tuts/c/stdlib/time/gmtime
- tuts/c/stdlib/time/strftime
- tuts/c/stdlib/time/time
- tuts/c/stdlib/time/timespec_get
Related notes
- tuts/c/stdlib Linked here; links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdint_stdbool_and_limits Linked here; links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/assert links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/assert/assert links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/floor links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/isnan links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/pow links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/sqrt links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/time links to this page; shared tags: #c, #prog, #stdlib