SLS AVR Lib 0.1a
 
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------------+
2// This file is part of SLS AVR Library
3// https://github.com/SimonLitt/sls-avr-lib
4// ---------------------------------------------------------------------------+
5// Copyright (C) 2025 Simon Litt <simon@1itt.net> https://coding.1itt.net,
6// https://github.com/SimonLitt
7//
8// This program is free software: you can redistribute it and/or modify it
9// under the terms of the GNU General Public License as published by the Free
10// Software Foundation, version 3.
11//
12// This program is distributed in the hope that it will be useful, but WITHOUT
13// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15// more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program. If not, see <https://www.gnu.org/licenses/>.
19// ---------------------------------------------------------------------------+
47
48#ifndef SLS_AVR_ASSERT_H_
49#define SLS_AVR_ASSERT_H_
50
51#include <assert.h>
52
53#if defined(NDEBUG)
54# define assert_na(e) ((void)0)
55#else // !NDEBUG
62# define assert_na(expression) ((expression) ? (void)0 : \
63 fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %u.\n", #expression, __func__ , __FILE__, __LINE__))
64#endif // NDEBUG
65
66
67#if defined(__DOXYGEN__)
68# define ASSERT_USE_ABORT
75# define ASSERT(expression)
76#endif // __DOXYGEN__
77
79#ifdef ASSERT_USE_ABORT
80# ifndef __ASSERT_USE_STDERR
81# define __ASSERT_USE_STDERR
82# endif // __ASSERT_USE_STDERR
83# define ASSERT(e) assert((e))
84#else
85# define ASSERT(e) assert_na((e))
86#endif // ASSERT_USE_ABORT
88
89#endif // SLS_AVR_ASSERT_H_
Alternative AVR assert.