|
cbase 1.46.11
C/C++ Static Template
|
Context detection, utilities, compiler abstractions, and data structures. More...
#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <string.h>

Go to the source code of this file.
Macros | |
| #define | BUILD_DEBUG 1 |
| Defined to 1 if compiling in Debug mode. | |
| #define | BUILD_NAME "Debug" |
| Human-readable string name of the build configuration. | |
| #define | C_STANDARD 89 |
| Integer representing the detected C standard version. | |
| #define | C_STANDARD_NAME "C89/Default" |
| Human-readable string of the detected C standard. | |
| #define | function static |
| File-scoped function (invisible to the linker). | |
| #define | global static |
| File-scoped global variable (invisible to the linker). | |
| #define | local_persist static |
| Function-scoped static variable (persists state across calls). | |
| #define | external extern |
| Externally linked variable or function. | |
| #define | thread_local _Thread_local |
| Declares a thread-local variable (each thread gets its own instance). | |
| #define | API_EXPORT |
| Exports a symbol from a shared library (.dll / .so). | |
| #define | API_LOCAL |
| Hides a symbol from a shared library (.dll / .so). | |
| #define | C_LINKAGE_BEGIN |
| Opens a C linkage block for C++ compilers (Empty in C). | |
| #define | C_LINKAGE_END |
| Closes a C linkage block for C++ compilers (Empty in C). | |
| #define | STRINGIFY_DETAIL(x) |
| Internal implementation of STRINGIFY. Do not use directly. | |
| #define | STRINGIFY(x) |
| Safely converts a macro argument into a string literal. | |
| #define | GLUE_DETAIL(x, y) |
| Internal implementation of GLUE. Do not use directly. | |
| #define | GLUE(x, y) |
| Safely concatenates two tokens together into a single token. | |
| #define | INT_FROM_PTR(ptr) |
| Safely casts a pointer to an integer of pointer size. | |
| #define | PTR_FROM_INT(type, val) |
| Safely casts a pointer-sized integer back to a specific pointer type. | |
| #define | ARRAY_SIZE(arr) |
| Calculates the number of elements in a statically allocated array. | |
| #define | MIN(a, b) |
| Returns the minimum of two values (Standard C fallback). | |
| #define | MAX(a, b) |
| Returns the maximum of two values (Standard C fallback). | |
| #define | CLAMP(val, min, max) |
| Clamps a value between a minimum and a maximum (Standard C fallback). | |
| #define | SWAP(type, a, b) |
| Generic variable swap. | |
| #define | Boolify(x) |
| Safely converts any scalar value to a strict 1 or 0 boolean. | |
| #define | AsciiID4(a, b, c, d) |
| Packs four 8-bit ASCII characters into a single 32-bit integer (FourCC). | |
| #define | ExpandAsciiID(x) |
| Expands a 32-bit FourCC integer for use in a printf format string (e.g. "%.*s"). | |
| #define | ALIGN_UP_POW2(x, p) |
| Aligns a value UP to the nearest power of 2. | |
| #define | ALIGN_DOWN_POW2(x, p) |
| Aligns a value DOWN to the nearest power of 2. | |
| #define | IS_POW2_OR_ZERO(x) |
| Checks if a given integer is a power of 2 (or zero). | |
| #define | SHIFT8(T, x, s) |
| Shifts a byte value to a specific bit position. | |
| #define | PACK_U32_LE(a, b, c, d) |
| Packs 4 bytes into a 32-bit unsigned integer (little-endian order). | |
| #define | MEM_ZERO(ptr, size) |
| Wraps memset to explicitly write 0s to a block of memory. | |
| #define | MEM_ZERO_STRUCT(ptr) |
| Zeroes out a struct securely using the pointer's inner type size. | |
| #define | MEM_ZERO_ARRAY(arr) |
| Zeroes out a static array securely using the array's full size. | |
| #define | MEM_COPY(dst, src, size) |
| Wraps memmove for standard memory copying. | |
| #define | MEM_COPY_STRUCT(dst, src) |
| Safely copies data from one struct pointer to another. | |
| #define | MEM_COPY_ARRAY(dst, src) |
| Safely copies data from one static array to another. | |
| #define | DLL_PUSH_BACK_NP(f, l, n, next, prev) |
| Pushes a node to the back of a doubly linked list (Custom pointer names). | |
| #define | DLL_PUSH_BACK(f, l, n) |
| Pushes a node to the back of a doubly linked list. | |
| #define | DLL_PUSH_FRONT(f, l, n) |
| Pushes a node to the front of a doubly linked list. | |
| #define | DLL_REMOVE_NP(f, l, n, next, prev) |
| Removes a node from a doubly linked list (Custom pointer names). | |
| #define | DLL_REMOVE(f, l, n) |
| Removes a node from a doubly linked list. | |
| #define | SLL_QUEUE_PUSH_N(f, l, n, next) |
| Pushes a node to a singly linked queue (Custom pointer name). | |
| #define | SLL_QUEUE_PUSH(f, l, n) |
| Pushes a node to the back of a singly linked queue. | |
| #define | SLL_STACK_PUSH_N(f, n, next) |
| Pushes a node to the top of a singly linked stack (Custom pointer name). | |
| #define | SLL_STACK_PUSH(f, n) |
| Pushes a node to the top of a singly linked stack. | |
| #define | SLL_STACK_POP_N(f, next) |
| Pops a node from the top of a singly linked stack (Custom pointer name). | |
| #define | SLL_STACK_POP(f) |
| Pops a node from the top of a singly linked stack. | |
| #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. | |
Context detection, utilities, compiler abstractions, and data structures.
A collection of macros for determining the compilation context (OS, compiler, architecture) without relying on external dependencies, as well as robust QoL macros for memory, math, linkage, and intrusive data structures.
Definition in file base_macros.h.
| #define BUILD_DEBUG 1 |
Defined to 1 if compiling in Debug mode.
Definition at line 96 of file base_macros.h.
| #define BUILD_NAME "Debug" |
Human-readable string name of the build configuration.
Definition at line 98 of file base_macros.h.
| #define C_STANDARD 89 |
Integer representing the detected C standard version.
Definition at line 138 of file base_macros.h.
| #define C_STANDARD_NAME "C89/Default" |
Human-readable string of the detected C standard.
Definition at line 140 of file base_macros.h.