Ylva And Malin
ym_assert.h
Go to the documentation of this file.
1 #pragma once
2 #include <ym_error.h>
3 #include <ym_log.h>
4 #include <stdlib.h>
5 
38 #if defined(YM_ASSERT_TERMINATE)
39 #define YM_ASSERT(expr, ym_errc, fmt, ...) \
40 if (YM_LIKELY(expr)) { } \
41 else \
42 { \
43  YM_ERROR("Assertion failure: " #expr ": " fmt, ##__VA_ARGS__); \
44 }
45 
46 #elif defined(YM_ASSERT_REPORT)
47 #define YM_ASSERT(expr, ym_errc, fmt, ...) \
48 if (YM_LIKELY(expr)) { } \
49 else \
50 { \
51  YM_WARN("Assertion failure: " #expr ": " fmt, ##__VA_ARGS__); \
52 }
53 
54 #elif defined(YM_ASSERT_ERRC)
55 #define YM_ASSERT(expr, ym_errc, fmt, ...) \
56 if (YM_LIKELY(expr)) { } \
57 else \
58 { \
59  ym_raise_error(ym_errc); \
60 }
61 
62 #else
63 #define YM_ASSERT(expr, ym_errc, fmt, ...)
64 #endif
65 
66 // Static assert does not get defined when compiling for windows
67 #ifdef WIN32
68 #define static_assert _Static_assert
69 #endif