From e6710f5ad898b54a4ae74d57858ba1287f0ef8bf Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 6 Oct 2024 13:32:00 -0400 Subject: lib: Cleanup types and assert sizeof(int) = 4 Signed-off-by: Andrew Opalach --- src/lib.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/lib.c b/src/lib.c index 063da23..0033463 100644 --- a/src/lib.c +++ b/src/lib.c @@ -1,5 +1,12 @@ #include "../include/al/lib.h" +// https://forum.vcfed.org/index.php?threads/c-item-size-check-at-compile-time.1244920/ +#define AL_ASSERT_TYPE_SIZE(type, size) \ + typedef char type##__size_test[( !!(sizeof(type) == size) )*2-1] + +AL_ASSERT_TYPE_SIZE(int, 4); +AL_ASSERT_TYPE_SIZE(unsigned, 4); + #if AL_USE_STDLIB static void *(*_al_malloc)(size_t) = malloc; static void *(*_al_calloc)(size_t, size_t) = calloc; -- cgit v1.2.3-101-g0448