Debug and Release assertion macro implementations for GCC/Clang platforms.
More...
Go to the source code of this file.
|
| #define | assert(expression) |
| | Debug assertion macro for runtime expression checking.
|
| #define | assert_message(expression, message) |
| | Debug assertion macro with custom message for runtime expression checking.
|
Debug and Release assertion macro implementations for GCC/Clang platforms.
Supplies assert and related debugging macros for Debug and Release builds.
- Note
- Included by platform_config.hpp on platforms that use this implementation; not a public module header.
◆ assert
| #define assert |
( |
| expression | ) |
|
Value:do { \
if (!(expression)) { \
if (std::is_constant_evaluated()) { \
toy::assertion::assertCompileTimeError(); \
} else { \
toy::assertion::assertion(#expression, nullptr, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} \
} \
} while (0)
Debug assertion macro for runtime expression checking.
This macro provides runtime assertion checking in debug builds. It evaluates the given expression and triggers an assertion failure if the expression is false. In release builds, this macro expands to nothing.
- Parameters
-
| expression | Boolean expression to check. Prefer side-effect-free. |
- Note
- This macro is only active in debug builds (_DEBUG defined).
-
In release builds, this macro expands to ((void)0) and has no effect.
-
Assertion failures will call toy::assertion::assertion with file, function, and line information.
-
The expression is evaluated only once and should not have side effects.
- Warning
- Do not rely on the expression being evaluated in release builds.
-
The expression should not have side effects as it may not be evaluated in release builds.
- See also
- assert_message, toy::assertion::assertion
◆ assert_message
| #define assert_message |
( |
| expression, |
|
|
| message ) |
Value:do { \
if (!(expression)) { \
if (std::is_constant_evaluated()) { \
toy::assertion::assertCompileTimeError(); \
} else { \
toy::assertion::assertion(#expression, message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} \
} \
} while (0)
Debug assertion macro with custom message for runtime expression checking.
This macro provides runtime assertion checking in debug builds with a custom error message. It evaluates the given expression and triggers an assertion failure with the provided message if the expression is false. In release builds, this macro expands to nothing.
- Parameters
-
| expression | Boolean expression to check. Prefer side-effect-free. |
| message | A custom error message to display on assertion failure. Must be a C string literal. |
- Note
- This macro is only active in debug builds (_DEBUG defined).
-
In release builds, this macro expands to ((void)0) and has no effect.
-
Assertion failures will call toy::assertion::assertion with file, function, line, and custom message.
-
The expression is evaluated only once and should not have side effects.
-
The message parameter is passed as-is to the assertion handler.
- Warning
- Do not rely on the expression being evaluated in release builds.
-
The expression should not have side effects as it may not be evaluated in release builds.
-
The message should be a C string literal for optimal performance.
- See also
- assert, toy::assertion::assertion