SLS AVR Lib 0.1a
 
Loading...
Searching...
No Matches
assert.h File Reference

Alternative AVR assert. More...

#include <assert.h>

Go to the source code of this file.

Macros

#define assert_na(expression)
 The assert_na() macro tests the given expression, like standard assert macro with __ASSERT_USE_STDERR definition, but don't call abort().
 
#define ASSERT_USE_ABORT
 Replaces the behavior of the ASSERT macro with the standard one.
 
#define ASSERT(expression)
 The macro tests the given expression.
 

Detailed Description

Alternative AVR assert.

Author
Simon Litt simon.nosp@m.@1it.nosp@m.t.net https://coding.1itt.net, https://github.com/SimonLitt

Because standard __assert calls abort() function.

#include <sls-avr/assert.h>
int main(void) {
...
assert_na(PIND == 0xF0);
...
}
Alternative AVR assert.
#define assert_na(expression)
The assert_na() macro tests the given expression, like standard assert macro with __ASSERT_USE_STDERR...
Definition assert.h:62
#define ASSERT_USE_ABORT
#include <sls-avr/assert.h>
int main(void) {
...
ASSERT(PIND == 0xF0);
...
}
#define ASSERT(expression)
The macro tests the given expression.
Definition assert.h:75

Macro Definition Documentation

◆ ASSERT

#define ASSERT ( expression)

The macro tests the given expression.

Depending on the ASSERT_USE_ABORT macro, it calls standard assert() or assert_na()

Parameters
expressionExpression to test for.
See also
ASSERT_USE_ABORT
assert_na
https://www.nongnu.org/avr-libc/user-manual/group__avr__assert.html

◆ assert_na

#define assert_na ( expression)
Value:
((expression) ? (void)0 : \
fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %u.\n", #expression, __func__ , __FILE__, __LINE__))

The assert_na() macro tests the given expression, like standard assert macro with __ASSERT_USE_STDERR definition, but don't call abort().

The macro may be removed at compile time by defining NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG).

Parameters
expressionExpression to test for.
See also
https://www.nongnu.org/avr-libc/user-manual/group__avr__assert.html

◆ ASSERT_USE_ABORT

#define ASSERT_USE_ABORT

Replaces the behavior of the ASSERT macro with the standard one.

Attention
If the macro is defined, it also defines the __ASSERT_USE_STDERR macro. *
See also
ASSERT