The friendly Operating System for the Internet of Things
assert.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 INRIA
3  * Copyright (C) 2016 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
22 #ifndef ASSERT_H
23 #define ASSERT_H
24 
25 #include "panic.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifdef DOXYGEN
32 
46 #define DEBUG_ASSERT_VERBOSE
47 #endif
48 
49 #ifndef RIOT_FILE_RELATIVE
50 #define RIOT_FILE_RELATIVE (__FILE__)
51 #endif
52 
56 extern const char assert_crash_message[];
57 
58 #ifdef NDEBUG
59 #define assert(ignore)((void) 0)
60 #elif defined(DEBUG_ASSERT_VERBOSE)
61 
71 NORETURN void _assert_failure(const char *file, unsigned line);
72 
104 #define assert(cond) \
105  if (!(cond)) { \
106  _assert_failure(RIOT_FILE_RELATIVE, __LINE__); \
107  }
108 #else
109 #define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, assert_crash_message))
110 #endif
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* ASSERT_H */
117 
const char assert_crash_message[]
the string that is passed to panic in case of a failing assertion
NORETURN void _assert_failure(const char *file, unsigned line)
Function to handle failed assertion.
Crash handling header.
#define NORETURN
The NORETURN keyword tells the compiler to assume that the function cannot return.