Update to LibConf system, added loading of dynamic libraries (only Linux for now) and some more fixes.

This commit is contained in:
2023-05-31 23:41:22 +02:00
parent da781b87f2
commit 920e83d4da
7 changed files with 106 additions and 52 deletions

View File

@@ -6,13 +6,7 @@
#include <cstdio>
#include <cstdlib>
namespace mijin
{
//
// public defines
//
#include <source_location>
#if MIJIN_DEBUG
#ifdef _WIN32
@@ -25,23 +19,33 @@ extern "C" __declspec(dllimport) void __stdcall DebugBreak();
#define MIJIN_TRAP() raise(SIGTRAP)
#define MIJIN_FUNC() "" // TODO: __PRETTY_FUNCTION__ is not working for some reason -.-
#endif // !_WIN32
#endif // MIJIN_DEBUG
#define MIJIN_DO_RAISE_ERROR(msg, func, file, line) \
switch (mijin::handleError(msg, func, file, line)) \
{ \
case mijin::ErrorHandling::CONTINUE: \
break; \
case mijin::ErrorHandling::TRAP: \
MIJIN_TRAP(); \
[[fallthrough]]; \
default: /* ABORT */ \
std::abort(); \
namespace mijin
{
//
// public defines
//
#if MIJIN_DEBUG
#define MIJIN_DO_RAISE_ERROR(msg, source_loc) \
switch (mijin::handleError(msg, source_loc)) \
{ \
case mijin::ErrorHandling::CONTINUE: \
break; \
case mijin::ErrorHandling::TRAP: \
MIJIN_TRAP(); \
[[fallthrough]]; \
default: /* ABORT */ \
std::abort(); \
}
#define MIJIN_RAISE_ERROR(msg, func, file, line) MIJIN_DO_RAISE_ERROR(msg, func, file, line)
#define MIJIN_ERROR(msg) \
MIJIN_RAISE_ERROR(msg, MIJIN_FUNC(), __FILE__, __LINE__)
MIJIN_DO_RAISE_ERROR(msg, std::source_location::current())
#define MIJIN_FATAL(msg) \
MIJIN_ERROR(msg) \
@@ -129,13 +133,11 @@ constexpr AssertionResult handleAssert(const char* /* condition */,
ErrorHandling handleError(const char* message, const char* function,
const char* file, int line) noexcept;
#else
inline ErrorHandling handleError(const char* message, const char* function,
const char* file, int line) noexcept
inline ErrorHandling handleError(const char* message, const std::source_location& location) noexcept
{
std::puts(message);
std::printf("Function: %s\n", function);
std::printf("File: %s\n", file);
std::printf("Line: %d\n", line);
std::printf("Function: %s\n", location.function_name());
std::printf("Location: %s:%d:%d\n", location.file_name(), location.line(), location.column());
(void) std::fflush(stdout);
return ErrorHandling::TRAP;
}