From 8f4ba2f57784d2fe3c9aa1b429c8c7657d698030 Mon Sep 17 00:00:00 2001 From: Mosder Date: Mon, 17 Aug 2026 12:18:25 +0200 Subject: docs: added documentation about defining macros to change how lib works --- include/moslib.h | 7 +++++++ include/moslib/ds/array.h | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/moslib.h b/include/moslib.h index 341db7e..b863678 100644 --- a/include/moslib.h +++ b/include/moslib.h @@ -2,6 +2,13 @@ // Main header file of the library // Contains all other header files +// By default the library doesn't force the use of a prefix +// You can force the use of the "mos" prefix by defining (before including any header): +// +// #define MOS_FORCE_PREFIXES +// +// This way you can, for example, avoid collisions + #include "moslib/ds/array.h" #include "moslib/mem/alloc.h" #include "moslib/tester.h" diff --git a/include/moslib/ds/array.h b/include/moslib/ds/array.h index 92dacbd..8f080a3 100644 --- a/include/moslib/ds/array.h +++ b/include/moslib/ds/array.h @@ -10,6 +10,9 @@ // // Then on the first usage of the array it's gonna be initialized. // You can use arr_set_cap function right after definition to initalize to the specified capacity. +// To set the default init capacity, define (before including the header): +// +// #define MOS_ARR_INIT_CAP // // ---------------------------------------------------------------------------------------------------- // @@ -522,7 +525,7 @@ typedef struct { size_t cap; } MosArrHeader; -#define mos_arr_p_diff(p1, p2) (((char *)(p1) - (char*)(p2)) / sizeof(*(p2))) +#define mos_arr_p_diff(p1, p2) (((char *)(p1) - (char *)(p2)) / sizeof(*(p2))) // Function prototypes for macros extern void mos_arr_append_fn(void *p_arr, size_t el_size, size_t init_cap); -- cgit v1.2.3