add more utilities

This commit is contained in:
DH 2024-09-03 10:10:27 +03:00
parent 86e2d8b129
commit d7f486fdc9
4 changed files with 47 additions and 0 deletions

26
rx/src/die.cpp Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include "die.hpp"
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
void rx::die(const char *message, ...) {
va_list args;
va_start(args, message);
std::vfprintf(stderr, message, args);
std::fprintf(stderr, "\n");
va_end(args);
std::abort();
}
void rx::dieIf(bool condition, const char *message, ...) {
if (condition) {
va_list args;
va_start(args, message);
std::vfprintf(stderr, message, args);
std::fprintf(stderr, "\n");
va_end(args);
std::abort();
}
}