#include "progname.qh"
-#define assert(expr, ...) _assert(LOG_SEVERE, expr, __VA_ARGS__)
+void print_assertfailed_severe(string expr);
+void print_assertfailed_fatal(string expr);
+
+#define assert(expr, ...) _assert(print_assertfailed_severe, expr, __VA_ARGS__)
#define devassert(...) MACRO_BEGIN if (autocvar_developer) assert(__VA_ARGS__); MACRO_END
#define assert_once(expr, ...) \
MACRO_END
#define devassert_once(...) MACRO_BEGIN if (autocvar_developer) assert_once(__VA_ARGS__); MACRO_END
-#define demand(expr, ...) _assert(LOG_FATAL, expr, __VA_ARGS__)
+#define demand(expr, ...) _assert(print_assertfailed_fatal, expr, __VA_ARGS__)
#define devdemand(...) MACRO_BEGIN if (autocvar_developer) demand(__VA_ARGS__); MACRO_END
#define _assert(f, expr, then) \
MACRO_BEGIN \
if (!(expr)) \
{ \
- f("assertion failed: `" #expr "`\n"); \
+ f(#expr); \
then; \
} \
MACRO_END
bt_cvar_set("developer", ftos(dev)); \
bt_cvar_set("prvm_backtraceforwarnings", ftos(war)); \
MACRO_END
+
+void print_assertfailed_severe(string expr)
+{
+ // this is inside a function to avoid expanding it on compilation everytime
+ LOG_SEVERE("assertion failed: `", expr, "`\n");
+}
+
+void print_assertfailed_fatal(string expr)
+{
+ // this is inside a function to avoid expanding it on compilation everytime
+ LOG_FATAL("assertion failed: `", expr, "`\n");
+}