This file contains assertion functions to be used throughout the codebase.
More...
Go to the source code of this file.
|
#define | KASSERTIONS_ENABLED |
|
#define | debugBreak() __builtin_trap() |
| Causes a debug breakpoint to be hit. More...
|
|
#define | KASSERT(expr) |
| Asserts the provided expression to be true, and logs a failure if not. Also triggers a breakpoint if debugging. More...
|
|
#define | KASSERT_MSG(expr, message) |
| Asserts the provided expression to be true, and logs a failure if not. Allows the user to specify a message to accompany the failure. Also triggers a breakpoint if debugging. More...
|
|
#define | KASSERT_DEBUG(expr) |
|
|
KAPI void | report_assertion_failure (const char *expression, const char *message, const char *file, i32 line) |
| Reports an assertion failure. Note that this is not the assertion itself, just a reporting of an assertion failure that has already occurred. More...
|
|
This file contains assertion functions to be used throughout the codebase.
- Author
- Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
- Version
- 1.0
- Date
- 2022-01-10
- Copyright
- Kohi Game Engine is Copyright (c) Travis Vroman 2021-2022
◆ debugBreak
#define debugBreak |
( |
| ) |
__builtin_trap() |
Causes a debug breakpoint to be hit.
◆ KASSERT
Value: { \
if (expr) { \
} else { \
report_assertion_failure(#expr, "", __FILE__, __LINE__); \
debugBreak(); \
} \
}
Asserts the provided expression to be true, and logs a failure if not. Also triggers a breakpoint if debugging.
- Parameters
-
expr | The expression to be evaluated. |
◆ KASSERT_DEBUG
#define KASSERT_DEBUG |
( |
|
expr | ) |
|
◆ KASSERT_MSG
#define KASSERT_MSG |
( |
|
expr, |
|
|
|
message |
|
) |
| |
Value: { \
if (expr) { \
} else { \
report_assertion_failure(#expr, message, __FILE__, __LINE__); \
debugBreak(); \
} \
}
Asserts the provided expression to be true, and logs a failure if not. Allows the user to specify a message to accompany the failure. Also triggers a breakpoint if debugging.
- Parameters
-
expr | The expression to be evaluated. |
message | The message to be reported along with the assertion failure. |
◆ KASSERTIONS_ENABLED
#define KASSERTIONS_ENABLED |
◆ report_assertion_failure()
KAPI void report_assertion_failure |
( |
const char * |
expression, |
|
|
const char * |
message, |
|
|
const char * |
file, |
|
|
i32 |
line |
|
) |
| |
Reports an assertion failure. Note that this is not the assertion itself, just a reporting of an assertion failure that has already occurred.
- Parameters
-
expression | The expression to be reported. |
message | A custom message to be reported, if provided. |
file | The path and name of the file containing the expression. |
line | The line number in the file where the assertion failure occurred. |