32 # if defined(__GNUC__)
33 # define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, __func__, # a)
34 # elif defined(_MSC_VER)
35 # define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, __func__, # a)
37 # define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, "<?>", # a)
40 # ifdef WITH_ASSERT_ABORT
41 # define _BLI_ASSERT_ABORT _BLI_assert_abort
43 # define _BLI_ASSERT_ABORT() (void)0
46 # define BLI_assert(a) \
47 (void)((!(a)) ? ((_BLI_assert_print_backtrace(), \
48 _BLI_ASSERT_PRINT_POS(a), \
49 _BLI_ASSERT_ABORT(), \
53 # define BLI_assert_msg(a, msg) \
54 (void)((!(a)) ? ((_BLI_assert_print_backtrace(), \
55 _BLI_ASSERT_PRINT_POS(a), \
56 _BLI_assert_print_extra(msg), \
57 _BLI_ASSERT_ABORT(), \
61 # define BLI_assert(a) ((void)0)
62 # define BLI_assert_msg(a, msg) ((void)0)
65 #if defined(__cplusplus)
67 # define BLI_STATIC_ASSERT(a, msg) static_assert(a, msg);
68 #elif defined(_MSC_VER)
70 # if (_MSC_VER > 1910) && !defined(__clang__)
71 # define BLI_STATIC_ASSERT(a, msg) static_assert(a, msg);
73 # define BLI_STATIC_ASSERT(a, msg) _STATIC_ASSERT(a);
75 #elif defined(__COVERITY__)
77 # define BLI_STATIC_ASSERT(a, msg)
78 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
80 # define BLI_STATIC_ASSERT(a, msg) _Static_assert(a, msg);
83 # define BLI_STATIC_ASSERT(a, msg)
86 #define BLI_STATIC_ASSERT_ALIGN(st, align) \
87 BLI_STATIC_ASSERT((sizeof(st) % (align) == 0), "Structure must be strictly aligned")
93 #define BLI_assert_unreachable() \
95 _BLI_assert_unreachable_print(__FILE__, __LINE__, __func__); \
96 BLI_assert_msg(0, "This line of code is marked to be unreachable."); \
void _BLI_assert_print_backtrace(void)
void _BLI_assert_print_extra(const char *str)
void _BLI_assert_abort(void)
void _BLI_assert_print_pos(const char *file, int line, const char *function, const char *id)
void _BLI_assert_unreachable_print(const char *file, int line, const char *function)