[ox/std] Leave panic unimplemented when C++ stdlib is absent
This commit is contained in:
parent
e59499b127
commit
ea14ccac3a
6
deps/ox/src/ox/std/assert.cpp
vendored
6
deps/ox/src/ox/std/assert.cpp
vendored
@ -34,12 +34,12 @@ void assertFunc<bool>([[maybe_unused]]const char *file, [[maybe_unused]]int line
|
||||
template<>
|
||||
void assertFunc<Error>(const char *file, int line, Error err, const char *msg) {
|
||||
if (err) {
|
||||
panic(file, line, err, msg);
|
||||
panic(file, line, msg, err);
|
||||
}
|
||||
}
|
||||
|
||||
void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) {
|
||||
#if defined(OX_USE_STDLIB)
|
||||
void panic(const char *file, int line, const char *msg, Error err) {
|
||||
std::cerr << "\033[31;1;1mPANIC:\033[0m (" << file << ':' << line << "): " << msg << '\n';
|
||||
std::cerr << "\tError Code:\t" << err << '\n';
|
||||
if (err.file != nullptr) {
|
||||
@ -48,7 +48,7 @@ void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_u
|
||||
printStackTrace(2);
|
||||
oxTrace("assert").del("") << "Failed assert: " << msg << " (" << file << ":" << line << ")";
|
||||
std::abort();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
8
deps/ox/src/ox/std/assert.hpp
vendored
8
deps/ox/src/ox/std/assert.hpp
vendored
@ -23,14 +23,14 @@ void assertFunc<bool>(const char *file, int line, bool pass, const char *msg);
|
||||
template<>
|
||||
void assertFunc<Error>(const char *file, int line, Error err, const char*);
|
||||
|
||||
void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg);
|
||||
void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]const char *msg, [[maybe_unused]]Error err = OxError(0));
|
||||
|
||||
}
|
||||
|
||||
#define oxPanic(pass, msg) ox::panic(__FILE__, __LINE__, pass, msg)
|
||||
#ifndef NDEBUG
|
||||
#define oxAssert(pass, msg) ox::assertFunc<decltype(pass)>(__FILE__, __LINE__, pass, msg)
|
||||
#define oxPanic(pass, msg) ox::panic(__FILE__, __LINE__, pass, msg)
|
||||
#else
|
||||
#define oxAssert(pass, msg)
|
||||
#define oxPanic(pass, msg)
|
||||
inline void oxAssert(bool, const char*) {}
|
||||
inline void oxAssert(ox::Error, const char*) {}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user