From 9417307a8e6601d44c6e4074f4f15704b6c5b68c Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 25 May 2022 01:07:48 -0500 Subject: [PATCH] [ox/std] Fix problems in building with GCC 12 --- deps/ox/src/ox/std/algorithm.hpp | 10 ++++++++++ deps/ox/src/ox/std/assert.cpp | 24 ++++++++++-------------- deps/ox/src/ox/std/strops.cpp | 11 +++++++++++ deps/ox/src/ox/std/vector.hpp | 1 + 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/deps/ox/src/ox/std/algorithm.hpp b/deps/ox/src/ox/std/algorithm.hpp index 31c81df8..d61e76ff 100644 --- a/deps/ox/src/ox/std/algorithm.hpp +++ b/deps/ox/src/ox/std/algorithm.hpp @@ -20,4 +20,14 @@ constexpr It find(It begin, It end, const T &value) { return end; } +template +constexpr It find_if(It begin, It end, auto predicate) { + for (; begin != end; ++begin) { + if (predicate(*begin)) { + return begin; + } + } + return end; +} + } \ No newline at end of file diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 7dd7b9c5..b49d6e16 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -15,21 +15,17 @@ namespace ox { void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]const char *panicMsg, [[maybe_unused]]const Error &err) noexcept { #ifdef OX_USE_STDLIB - if (!std::is_constant_evaluated()) { - oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg); - if (err.msg) { - oxErrf("\tError Message:\t{}\n", err.msg); - } - oxErrf("\tError Code:\t{}\n", static_cast(err)); - if (err.file != nullptr) { - oxErrf("\tError Location:\t{}:{}\n", err.file, err.line); - } - printStackTrace(2); - oxTrace("panic").del("") << "Panic: " << panicMsg << " (" << file << ":" << line << ")"; - std::abort(); - } else { - assert(false); + oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg); + if (err.msg) { + oxErrf("\tError Message:\t{}\n", err.msg); } + oxErrf("\tError Code:\t{}\n", static_cast(err)); + if (err.file != nullptr) { + oxErrf("\tError Location:\t{}:{}\n", err.file, err.line); + } + printStackTrace(2); + oxTrace("panic").del("") << "Panic: " << panicMsg << " (" << file << ":" << line << ")"; + std::abort(); #endif } diff --git a/deps/ox/src/ox/std/strops.cpp b/deps/ox/src/ox/std/strops.cpp index d51845d9..dd9fea51 100644 --- a/deps/ox/src/ox/std/strops.cpp +++ b/deps/ox/src/ox/std/strops.cpp @@ -28,3 +28,14 @@ static_assert([] { retval |= !(ox_lastIndexOf(testStr, 'a', ox_strlen(testStr)) == 3); return retval == 0; }(), "ox_lastIndexOf aaaa a"); + +#ifndef OX_USE_STDLIB + +extern "C" +std::size_t strlen(const char *str) { + std::size_t len = 0; + for (; str[len]; len++); + return len; +} + +#endif diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index bfc319ff..b55e5858 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -9,6 +9,7 @@ #pragma once #include "bit.hpp" +#include "error.hpp" #include "initializerlist.hpp" #include "iterator.hpp" #include "math.hpp"