From ea14ccac3a5a57bc475c23d6d44f249411e8f648 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 11 Feb 2020 21:10:36 -0600 Subject: [PATCH] [ox/std] Leave panic unimplemented when C++ stdlib is absent --- deps/ox/src/ox/std/assert.cpp | 6 +++--- deps/ox/src/ox/std/assert.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index e2713cc3..8cba5ffe 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -34,12 +34,12 @@ void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line template<> void assertFunc(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 } diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index 424bf697..fd7e19f8 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -23,14 +23,14 @@ void assertFunc(const char *file, int line, bool pass, const char *msg); template<> void assertFunc(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(__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