-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertions.hpp
More file actions
40 lines (30 loc) · 984 Bytes
/
Copy pathAssertions.hpp
File metadata and controls
40 lines (30 loc) · 984 Bytes
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
#pragma once
#include "Compiler.hpp"
#if defined(CF_DEBUG)
#define CF_ASSERT_ENABLED 1
#else
#define CF_ASSERT_ENABLED 0
#endif
namespace Caffeine {
CF_NORETURN void assertFailed(const char* condition, const char* file, int line, const char* msg);
#if CF_ASSERT_ENABLED
#define CF_ASSERT(cond, msg) \
((cond) ? (void)0 : Caffeine::assertFailed(#cond, __FILE__, __LINE__, msg))
#else
#define CF_ASSERT(cond, msg) ((void)0)
#endif
#define CF_UNREACHABLE() Caffeine::assertFailed("CF_UNREACHABLE", __FILE__, __LINE__, "Unreachable code executed")
#define CF_ASSERT_NOT_NULL(ptr) CF_ASSERT((ptr) != nullptr, "Pointer must not be null")
#if defined(CF_DEBUG)
#define CF_DEBUG_ONLY(x) x
#else
#define CF_DEBUG_ONLY(x)
#endif
inline CF_NORETURN void assertFailed(const char* condition, const char* file, int line, const char* msg) {
(void)condition;
(void)file;
(void)line;
(void)msg;
CF_BUILTIN_TRAP();
}
} // namespace Caffeine