mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
9449078a9b
* assert toggle * Update Assert.h
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include "Assert.h"
|
|
|
|
#ifndef NO_ASSERT
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#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());
|
|
}
|
|
}
|
|
|
|
#endif
|