KallistiOS
##version##
|
Standard C Assertions. More...
#include <kos/cdefs.h>
Go to the source code of this file.
Macros | |
#define | _assert(e) assert(e) |
#define | assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, NULL, __FUNCTION__)) |
Standard C assertion macro. More... | |
#define | assert_msg(e, m) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, m, __FUNCTION__)) |
assert() with a custom message. More... | |
Typedefs | |
typedef void(* | assert_handler_t )(const char *file, int line, const char *expr, const char *msg, const char *func) |
Assertion handler type. More... | |
Functions | |
assert_handler_t | assert_set_handler (assert_handler_t hnd) |
Set an assertion handler to call on a failed assertion. More... | |
Standard C Assertions.
This file contains the standard C assertions to raise an assertion or to change the assertion handler.
#define _assert | ( | e | ) | assert(e) |
#define assert | ( | e | ) | ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, NULL, __FUNCTION__)) |
Standard C assertion macro.
This macro does a standard C assertion, wherein the expression is evaluated, and if false, the program is ultimately aborted using abort(). If the expression evaluates to true, the macro does nothing (other than any side effects of evaluating the expression).
e | A value or expression to be evaluated as true or false. |
#define assert_msg | ( | e, | |
m | |||
) | ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, m, __FUNCTION__)) |
typedef void(* assert_handler_t)(const char *file, int line, const char *expr, const char *msg, const char *func) |
Assertion handler type.
The user can provide their own assertion handler with this type. If none is provided, a default is used which ultimately prints out the location of the failed assertion and calls abort().
file | The filename where the assertion happened. |
line | The line number where the assertion happened. |
expr | The expression that raised the assertion. |
msg | A custom message for why the assertion happened. |
func | The function name from which the assertion happened. |
assert_handler_t assert_set_handler | ( | assert_handler_t | hnd | ) |
Set an assertion handler to call on a failed assertion.
The default assertion handler simply will print a message and call abort().