htils 1
A small set of utilities for C programming.
Loading...
Searching...
No Matches
assert.h File Reference
#include <htils/basictypes.h>

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define htils_assert(expr)
 

Functions

_Noreturn void __htils_assert_fail (const cstr *expr_str, const cstr *executable, const cstr *file, u32 line, const cstr *func)
 Terminates the program with an error message.
 

Variables

cstrprogram_invocation_short_name
 The name of the program, exposed by the GNU standard.
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

For using the GNU extension program_invocation_short_name

◆ htils_assert

#define htils_assert (   expr)
Value:
((expr) ? (void)0 \
__FILE__, __LINE__, __func__))
cstr * program_invocation_short_name
The name of the program, exposed by the GNU standard.
_Noreturn void __htils_assert_fail(const cstr *expr_str, const cstr *executable, const cstr *file, u32 line, const cstr *func)
Terminates the program with an error message.
Definition assert.c:11

Function Documentation

◆ __htils_assert_fail()

_Noreturn void __htils_assert_fail ( const cstr expr_str,
const cstr executable,
const cstr file,
u32  line,
const cstr func 
)

Terminates the program with an error message.

Prints the error message to stderr, and then terminates the program using exit().

Note
This function should never be run directly, and is run by htils_assert() on a failed assertion.
Parameters
expr_strThe expression as string.
executableThe executable name.
fileThe file name.
lineThe line number.
funcThe function name.
See also
htils_assert(), exit()

Variable Documentation

◆ program_invocation_short_name

cstr* program_invocation_short_name
extern

The name of the program, exposed by the GNU standard.

This variable is exposed by the GNU standard, and is used to get the program name without relying on argv[0].

Note
This variable depends on GNU extensions, and is not portable.