cbase 1.46.11
C/C++ Static Template
Loading...
Searching...
No Matches
Debugging & Context

Assertions and debugging breakpoints. More...

Macros

#define debug_break()
 Triggers a crash (segfault) as a fallback breakpoint.
#define ASSERT(expr)
 Standard runtime assertion. Triggers a debug break on failure.
#define ASSERT_NOT_NULL(ptr)
 Asserts that a given pointer is not NULL.

Detailed Description

Assertions and debugging breakpoints.

Macro Definition Documentation

◆ ASSERT

#define ASSERT ( expr)
Value:
do { \
if (!(expr)) { \
fputs("Assertion failed: " #expr "\n", stderr); \
fputs("File: " __FILE__ "\n", stderr); \
fputs("Line: " STRINGIFY(__LINE__) "\n", stderr); \
debug_break(); \
} \
} while (0)
#define STRINGIFY(x)
Safely converts a macro argument into a string literal.

Standard runtime assertion. Triggers a debug break on failure.

Parameters
exprThe expression that must evaluate to true (non-zero).

Definition at line 590 of file base_macros.h.

◆ ASSERT_NOT_NULL

#define ASSERT_NOT_NULL ( ptr)
Value:
do { \
if ((ptr) == NULL) { \
fputs("Assertion failed: " #ptr " is NULL\n", stderr); \
fputs("File: " __FILE__ "\n", stderr); \
fputs("Line: " STRINGIFY(__LINE__) "\n", stderr); \
debug_break(); \
} \
} while (0)

Asserts that a given pointer is not NULL.

Parameters
ptrThe pointer to check.

Definition at line 604 of file base_macros.h.

◆ debug_break

#define debug_break ( )
Value:
(*(volatile int *)0 = 0)

Triggers a crash (segfault) as a fallback breakpoint.

Definition at line 582 of file base_macros.h.