Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
Assert.hpp File Reference

Assertion and verification macros for runtime checks. More...

#include "RType/Logger.hpp"
#include <cstdlib>
Include dependency graph for Assert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RTP_DEBUG_BREAK()   std::abort()
 Platform-specific debug break macro.
 
#define RTP_ASSERT(condition, msg, ...)
 Assertion macro (Debug mode)
 
#define RTP_VERIFY(condition, msg, ...)    RTP_ASSERT(condition, msg, ##__VA_ARGS__)
 Verification macro (Debug mode)
 

Detailed Description

Assertion and verification macros for runtime checks.

Author
Robin Toillon

Provides platform-independent assertion macros with different behaviors in debug and release builds.

Definition in file Assert.hpp.

Macro Definition Documentation

◆ RTP_ASSERT

#define RTP_ASSERT (   condition,
  msg,
  ... 
)
Value:
do { \
if (!(condition)) [[unlikely]] { \
rtp::log::fatal("ASSERTION FAILED: " msg, ##__VA_ARGS__); \
RTP_DEBUG_BREAK(); \
} \
} while(0)

Assertion macro (Debug mode)

In debug builds (NDEBUG not defined), logs a fatal error and breaks into debugger if condition is false.

Parameters
conditionThe condition to assert
msgError message format string
...Optional format arguments
Note
Program execution stops if assertion fails

Definition at line 113 of file Assert.hpp.

◆ RTP_DEBUG_BREAK

#define RTP_DEBUG_BREAK ( )    std::abort()

Platform-specific debug break macro.

Triggers a debugger breakpoint or aborts execution depending on platform:

  • MSVC: Uses __debugbreak()
  • GCC/Clang: Uses __builtin_trap()
  • Other: Uses std::abort()

Definition at line 61 of file Assert.hpp.

◆ RTP_VERIFY

#define RTP_VERIFY (   condition,
  msg,
  ... 
)     RTP_ASSERT(condition, msg, ##__VA_ARGS__)

Verification macro (Debug mode)

In debug builds, behaves identically to RTP_ASSERT.

Parameters
conditionThe condition to verify
msgError message format string
...Optional format arguments

Definition at line 130 of file Assert.hpp.