Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
assert.hpp File Reference
#include <helios/compiler/compiler.hpp>
#include <helios/platform/platform.hpp>
#include <helios/utils/macro.hpp>
#include <cstdio>
#include <cstdlib>
#include <format>
#include <functional>
#include <source_location>
#include <string>
#include <string_view>

Go to the source code of this file.

Namespaces

namespace  helios
namespace  helios::details

Macros

#define HELIOS_ASSERT(condition, ...)
 Assertion macro that aborts execution in debug builds.
#define HELIOS_INVARIANT(condition, ...)
 Invariant check that asserts in debug builds and logs error in release.
#define HELIOS_VERIFY(condition, ...)
 Verify macro that always checks the condition.

Typedefs

using helios::AssertionHandler
 Function signature for custom assertion handlers.

Functions

std::string helios::details::FormatAssertionMessage (std::string_view condition, const std::source_location &loc, std::string_view message)
 Formats a complete assertion failure message with source location and stack trace.
void helios::details::DefaultAssertionHandler (std::string_view condition, const std::source_location &loc, std::string_view message) noexcept
 Default assertion handler that prints to stderr.
bool helios::details::HasLogPluginHandler () noexcept
 Log plugin assertion handler (weak symbol).
void helios::details::LogPluginAssertionHandler (std::string_view condition, const std::source_location &loc, std::string_view message) noexcept
 Weak symbol for log plugin assertion handler.
void helios::details::HandleAssertion (std::string_view condition, const std::source_location &loc, std::string_view message) noexcept
 Unified assertion handling function.
void helios::SetAssertionHandler (AssertionHandler handler) noexcept
 Sets a custom assertion handler.
AssertionHandler helios::GetAssertionHandler () noexcept
 Gets the current custom assertion handler.
void helios::AbortWithStacktrace (std::string_view message) noexcept
 Prints a message with stack trace and aborts the program execution.

Variables

constexpr AssertionHandler helios::kDefaultAssertionHandler = nullptr
 Default assertion handler (nullptr means use built-in default behavior).
constexpr bool helios::details::kEnableAssert = false
AssertionHandler helios::details::g_custom_assertion_handler = nullptr
 Storage for the custom assertion handler.

Macro Definition Documentation

◆ HELIOS_ASSERT

#define HELIOS_ASSERT ( condition,
... )

Assertion macro that aborts execution in debug builds.

Does nothing in release builds. Uses the configured assertion handler (custom -> log plugin -> default). Supports format strings and arguments.

Parameters
conditionThe condition to check
...Optional message (can be format string with arguments)

Definition at line 259 of file assert.hpp.

◆ HELIOS_INVARIANT

#define HELIOS_INVARIANT ( condition,
... )

Invariant check that asserts in debug builds and logs error in release.

Provides runtime safety checks that are enforced even in release builds. In debug builds, triggers assertion. In release builds, logs error and continues.

Parameters
conditionThe condition to check
...Optional message (can be format string with arguments)

Definition at line 295 of file assert.hpp.

◆ HELIOS_VERIFY

#define HELIOS_VERIFY ( condition,
... )

Verify macro that always checks the condition.

Similar to assert but runs in both debug and release builds. Useful for validating external input or critical invariants.

Parameters
conditionThe condition to check
...Optional message (can be format string with arguments)

Definition at line 323 of file assert.hpp.