KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Typedefs | Functions
assert.h File Reference

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.
#define assert_msg(e, m)   ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, m, __FUNCTION__))
 assert() with a custom message.

Typedefs

typedef void(* assert_handler_t )(const char *file, int line, const char *expr, const char *msg, const char *func)
 Assertion handler type.

Functions

assert_handler_t assert_set_handler (assert_handler_t hnd)
 Set an assertion handler to call on a failed assertion.

Detailed Description

Standard C Assertions.

This file contains the standard C assertions to raise an assertion or to change the assertion handler.

Author:
Dan Potter

Macro Definition Documentation

#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).

Parameters:
eA value or expression to be evaluated as true or false.
#define assert_msg (   e,
 
)    ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e, m, __FUNCTION__))

assert() with a custom message.

This macro acts the same as the assert() macro, but allows you to specify a custom message to be printed out if the assertion fails.

Parameters:
eA value or expression to be evaluated as true or false.
mA message (const char *).

Typedef Documentation

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().

Parameters:
fileThe filename where the assertion happened.
lineThe line number where the assertion happened.
exprThe expression that raised the assertion.
msgA custom message for why the assertion happened.
funcThe function name from which the assertion happened.
See also:
assert_set_handler

Function Documentation

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().

Returns:
The old assertion handler so it may be restored later if appropriate.
See also:
assert_handler_t