10 #define RZ_STATIC_ASSERT(x) \
18 #if defined(__GNUC__) && defined(__cplusplus)
19 #define RZ_FUNCTION ((const char *)(__PRETTY_FUNCTION__))
20 #elif defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
21 #define RZ_FUNCTION ((const char *)(__func__))
22 #elif defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300))
23 #define RZ_FUNCTION ((const char *)(__FUNCTION__))
25 #warning Do not know how to get function name in this setup
26 #define RZ_FUNCTION ((const char *)("???"))
29 #define rz_warn_if_reached() \
31 rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s code should not be reached\n", \
32 __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : ""); \
35 #define rz_warn_if_fail(expr) \
38 rz_assert_log(RZ_LOGLVL_WARN, "(%s:%d):%s%s runtime check failed: (%s)\n", \
39 __FILE__, __LINE__, RZ_FUNCTION, RZ_FUNCTION[0] ? ":" : "", #expr); \
51 #ifndef RZ_CHECKS_LEVEL
52 #define RZ_CHECKS_LEVEL 2
55 #if RZ_CHECKS_LEVEL == 0
57 #define rz_return_if_fail(expr) \
61 #define rz_return_val_if_fail(expr, val) \
65 #define rz_return_if_reached() \
69 #define rz_return_val_if_reached(val) \
74 #elif RZ_CHECKS_LEVEL == 1 || RZ_CHECKS_LEVEL == 2
76 #if RZ_CHECKS_LEVEL == 1
77 #define H_LOG_(loglevel, fmt, ...)
79 #define H_LOG_(loglevel, fmt, ...) rz_assert_log(loglevel, fmt, __VA_ARGS__)
100 #define rz_return_if_fail(expr) \
103 H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d)\n", RZ_FUNCTION, #expr, __LINE__); \
108 #define rz_return_val_if_fail(expr, val) \
111 H_LOG_(RZ_LOGLVL_WARN, "%s: assertion '%s' failed (line %d)\n", RZ_FUNCTION, #expr, __LINE__); \
116 #define rz_return_if_reached() \
118 H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached\n", __FILE__, __LINE__, RZ_FUNCTION); \
122 #define rz_return_val_if_reached(val) \
124 H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached\n", __FILE__, __LINE__, RZ_FUNCTION); \
128 #define rz_goto_if_reached(where) \
130 H_LOG_(RZ_LOGLVL_ERROR, "file %s: line %d (%s): should not be reached; jumping to %s\n", __FILE__, __LINE__, RZ_FUNCTION, #where); \
138 #define rz_return_if_fail(expr) \
142 #define rz_return_val_if_fail(expr, val) \
146 #define rz_return_if_reached() \
150 #define rz_return_val_if_reached(val) \
RZ_API void rz_assert_log(RzLogLevel level, const char *fmt,...) RZ_PRINTF_CHECK(2
enum rz_log_level RzLogLevel
#define RZ_PRINTF_CHECK(fmt, dots)