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