avr_assert(3avr)
π NAME π
avr_assert β this is the <assert.h> situation bestie, aka Diagnostics π©Ίβ¨ (and yep, it lives in section 3avr, iykyk)
β¨ SYNOPSIS β¨
Macros
#define assert(expression)
πΈ DETAILED DESCRIPTION πΈ
First things first, you gotta pull it in:
#include <assert.h>
Okay so this header file defines a debugging aid. That's the whole vibe. ππ
Here's the tea though, and it's kind of a big deal: there is no standard error output stream available for many applications using this library π. So the generation of a printable error message is not enabled by default. Not me being quiet on purpose, it's just how it is.
Those messages will only be generated if the application defines the macro
__ASSERT_USE_STDERR
before including the <assert.h> header file. Timing matters, bestie β° β macro goes first, include goes after, no exceptions.
By default, only abort() will be called to halt the application. π
π MACRO DEFINITION DOCUMENTATION π
#define assert( expression)
Parameters
expressionβ Expression to test for.
Okay so the assert() macro tests the given expression, and if it's false, the calling process is terminated π. A diagnostic message is written to stderr and the function abort() is called, effectively terminating the program. It's giving dramatic exit, but make it correct.
If expression is true, the assert() macro does nothing. Just sits there, silent, iconic, unbothered. π§ββοΈ
And here's the glow-up tip: the assert() macro may be removed at compile time by defining NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG). Poof, gone, no cap. β¨
β οΈ Heads up bestie: false expression = process gets terminated. This is not a drill, this is abort(). π¨
π AUTHOR π
Generated automatically by Doxygen for AVR-LibC from the source code. π€π
That's the whole page, fr fr π«Ά β brought to you by AVR-LibC, Version 2.2.1, and yeah she's avr_assert(3avr) through and through. Go forth and assert responsibly, my main character π
πΈπ
π¦ where this page comes from
- ubuntu resolute: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- ubuntu stonking: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms