iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
assertions.hpp File Reference

Go to the source code of this file.

Macros

#define IOX2_PANIC(message)   iox2::legacy::er::forwardPanic(iox2::bb::detail::SourceLocation::current(), message)
 calls panic handler and does not return
 
#define IOX2_ASSERT_INTERNAL(location, condition, stringified_condition, message)
 Only for internal usage.
 
#define IOX2_ASSERT(condition, message)    IOX2_ASSERT_INTERNAL(iox2::bb::detail::SourceLocation::current(), condition, #condition, message)
 only for debug builds: report fatal assert violation if expression evaluates to false
 
#define IOX2_ENFORCE_INTERNAL(location, condition, stringified_condition, message)
 Only for internal usage.
 
#define IOX2_ENFORCE(condition, message)    IOX2_ENFORCE_INTERNAL(iox2::bb::detail::SourceLocation::current(), condition, #condition, message)
 report fatal enforce violation if expression evaluates to false
 
#define IOX2_UNREACHABLE()
 panic if control flow reaches this code at runtime
 
#define IOX2_TODO()   iox2::legacy::er::forwardPanic(iox2::bb::detail::SourceLocation::current(), "Not yet implemented!")
 panic if control flow reaches this code at runtime and tells the user that this part of the code is not yet implemented
 

Macro Definition Documentation

◆ IOX2_ASSERT

#define IOX2_ASSERT (   condition,
  message 
)     IOX2_ASSERT_INTERNAL(iox2::bb::detail::SourceLocation::current(), condition, #condition, message)

only for debug builds: report fatal assert violation if expression evaluates to false

Note
for conditions that should not happen with correct use
Parameters
conditionboolean expression that must hold
messagemessage to be forwarded in case of violation

Definition at line 63 of file assertions.hpp.

◆ IOX2_ASSERT_INTERNAL

#define IOX2_ASSERT_INTERNAL (   location,
  condition,
  stringified_condition,
  message 
)
Value:
iox2::legacy::er::forwardFatalError(iox2::legacy::er::Violation::createAssertViolation(), \
location, \
stringified_condition, \
message); \
} \
[]() -> void { }()
static Violation createAssertViolation()
Definition violation.hpp:84
constexpr AssertViolationKind ASSERT_VIOLATION

Only for internal usage.

Definition at line 49 of file assertions.hpp.

◆ IOX2_ENFORCE

#define IOX2_ENFORCE (   condition,
  message 
)     IOX2_ENFORCE_INTERNAL(iox2::bb::detail::SourceLocation::current(), condition, #condition, message)

report fatal enforce violation if expression evaluates to false

Note
for conditions that may actually happen during correct use
Parameters
conditionboolean expression that must hold
messagemessage to be forwarded in case of violation

Definition at line 81 of file assertions.hpp.

◆ IOX2_ENFORCE_INTERNAL

#define IOX2_ENFORCE_INTERNAL (   location,
  condition,
  stringified_condition,
  message 
)
Value:
if (!(condition)) { \
iox2::legacy::er::forwardFatalError(iox2::legacy::er::Violation::createEnforceViolation(), \
location, \
stringified_condition, \
message); \
} \
[]() -> void { }()
static Violation createEnforceViolation()
Definition violation.hpp:88
constexpr EnforceViolationKind ENFORCE_VIOLATION

Only for internal usage.

Definition at line 67 of file assertions.hpp.

◆ IOX2_PANIC

#define IOX2_PANIC (   message)    iox2::legacy::er::forwardPanic(iox2::bb::detail::SourceLocation::current(), message)

calls panic handler and does not return

Parameters
messagemessage to be forwarded
Note
could actually throw if desired without breaking control flow asssumptions

Definition at line 39 of file assertions.hpp.

◆ IOX2_TODO

#define IOX2_TODO ( )    iox2::legacy::er::forwardPanic(iox2::bb::detail::SourceLocation::current(), "Not yet implemented!")

panic if control flow reaches this code at runtime and tells the user that this part of the code is not yet implemented

Definition at line 91 of file assertions.hpp.

◆ IOX2_UNREACHABLE

#define IOX2_UNREACHABLE ( )
Value:
iox2::legacy::er::detail::unreachable_wrapped<void, void>(iox2::bb::detail::SourceLocation::current(), \
"Reached code that was supposed to be unreachable.")
static constexpr auto current(const char *file=__builtin_FILE(), const uint32_t line=__builtin_LINE(), const char *function=__builtin_FUNCTION()) noexcept -> SourceLocation

panic if control flow reaches this code at runtime

Definition at line 85 of file assertions.hpp.