From 4f3ae943dba6bafedad3e70efdd040b81e73faa2 Mon Sep 17 00:00:00 2001 From: MechSlayer <0jcrespo1996@gmail.com> Date: Sat, 6 Sep 2025 01:25:14 +0200 Subject: [PATCH] feature: add DRANG_BIT_CAST macro for type-safe bit casting --- Source/DrangPlatform/Include/drang/platform.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/DrangPlatform/Include/drang/platform.h b/Source/DrangPlatform/Include/drang/platform.h index fcaca42..d162d0b 100644 --- a/Source/DrangPlatform/Include/drang/platform.h +++ b/Source/DrangPlatform/Include/drang/platform.h @@ -36,11 +36,9 @@ # define DRANG_ALLOC_ALIGN_ATTR(idx) __attribute__((alloc_align(idx))) # define DRANG_MALLOC_ATTR __attribute__((malloc)) + +#define DRANG_BIT_CAST(_Expr_, _From_, _To_) __builtin_bit_cast(_To_, _Expr_) + #else -# define DRANG_PRINTF_ATTR(fmt_idx, arg_idx) -# define DRANG_VPRINTF_ATTR(fmt_idx) -# define DRANG_ALLOC_SIZE_COUNT_ATTR(idx, count) -# define DRANG_ALLOC_SIZE_ATTR(idx) -# define DRANG_ALLOC_ALIGN_ATTR(idx) -# define DRANG_MALLOC_ATTR +#error "Unsupported compiler, please implement attribute macros" #endif