WinTer 0.1.1
Windows Terminal Emulator
Loading...
Searching...
No Matches
Debugging & Context

Assertions and context printing utilities. More...

Macros

#define debug_break()
 Triggers a native breakpoint in GDB/LLDB.
#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.

Functions

static void print_context_info (void)
 Prints OS, architecture, compiler, endianness, build, and C standard to stdout.

Detailed Description

Assertions and context printing utilities.

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 581 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 595 of file base_macros.h.

◆ debug_break

#define debug_break ( )
Value:
__builtin_trap()

Triggers a native breakpoint in GDB/LLDB.

Definition at line 570 of file base_macros.h.

Function Documentation

◆ print_context_info()

void print_context_info ( void )
inlinestatic

Prints OS, architecture, compiler, endianness, build, and C standard to stdout.

Useful as a one-line sanity check at application startup to confirm the binary was compiled with the expected settings.

Example output:

Compilation Context:
- Compiler: Clang
- OS: Windows
- Architecture: x86_64
- Endianness: Little Endian
- Build: Debug
- C Standard: C11

Definition at line 554 of file base_macros.h.

Here is the caller graph for this function: