-
Notifications
You must be signed in to change notification settings - Fork 1
/
cake_Assert.h
42 lines (34 loc) · 1.68 KB
/
cake_Assert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include "cake_Namespace.h"
#include "cake_Debug.h"
#define AVR__STRINGIFY(s) #s
#define AVR_STRINGIFY(s) AVR__STRINGIFY(s)
#ifdef AVR_BREAK_ON_ASSERT
# include <avr/interrupt.h>
# define avr_assert_break { cli(); while(1); }
#else
# define avr_assert_break ((void)0)
#endif
#define avr_assertion_str "Assert:" __FILE__ ":" AVR_STRINGIFY(__LINE__)
#define avr_log_assertion CAKE_NAMESPACE::Debug::log(avr_assertion_str)
#ifdef NDEBUG
# define avr_assert(...) ((void)0)
#else
# define avr_assert(condition) \
{ \
if (!(condition)) \
{ \
avr_log_assertion; \
avr_assert_break; \
} \
}
#endif
// -----------------------------------------------------------------------------
#define AVR_ASSERT(Predicate, ...) avr_assert(Predicate)
#define AVR_ASSERT_FALSE(...) avr_assert(false)
#define AVR_STATIC_ASSERT(Predicate) static_assert(Predicate, "")
#define AVR_IMPLEMENT_ME(...) \
{ \
static const bool ImplementMe = false; \
AVR_ASSERT(ImplementMe); \
}