mirror of
https://github.com/open-goal/jak-project
synced 2026-05-24 07:11:15 -04:00
c4a92571b2
* ci: fix windows releases (hopefully) * scripts: fix Taskfile file references for linux * asserts: add `ASSERT_MSG` macro and ensure `stdout` is flushed before `abort`ing * asserts: refactor all `assert(false);` with a preceeding message instances * lint: format * temp... * fix compiler errors * assert: allow for string literals in `ASSERT_MSG` * lint: formatting * revert temp change for testing
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
#include "Assert.h"
|
|
#include <string_view>
|
|
|
|
void private_assert_failed(const char* expr,
|
|
const char* file,
|
|
int line,
|
|
const char* function,
|
|
const char* msg) {
|
|
if (!msg || msg[0] == '\0') {
|
|
fprintf(stderr, "Assertion failed: '%s'\n\tSource: %s:%d\n\tFunction: %s\n", expr, file, line,
|
|
function);
|
|
} else {
|
|
fprintf(stderr, "Assertion failed: '%s'\n\tMessage: %s\n\tSource: %s:%d\n\tFunction: %s\n",
|
|
expr, msg, file, line, function);
|
|
}
|
|
fflush(stdout); // ensure any stdout logs are flushed before we terminate
|
|
fflush(stderr);
|
|
abort();
|
|
}
|
|
|
|
void private_assert_failed(const char* expr,
|
|
const char* file,
|
|
int line,
|
|
const char* function,
|
|
const std::string_view& msg) {
|
|
if (msg.empty()) {
|
|
private_assert_failed(expr, file, line, function);
|
|
} else {
|
|
private_assert_failed(expr, file, line, function, msg.data());
|
|
}
|
|
}
|