diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-04-09 02:42:35 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-04-09 02:42:35 +0330 |
commit | 90690900cedbbf8004f5b452dae04166818f99fc (patch) | |
tree | ea066c3378ac6460e394f3d9ebe90a1707ad0d18 /src/utils/type.c | |
parent | d76c19e0bea07806c49175c91d19eb38cfb230dd (diff) |
convert assert to static_assert for no unnecesary runtime overhead
Diffstat (limited to 'src/utils/type.c')
-rw-r--r-- | src/utils/type.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/utils/type.c b/src/utils/type.c index a46be5a..09b9c36 100644 --- a/src/utils/type.c +++ b/src/utils/type.c @@ -1,24 +1,20 @@ #include "type.h" -#include <assert.h> +static_assert(sizeof(bool) == (8 / 8), "Bad size"); -void checkTypes() { - assert(sizeof(bool) == (8 / 8)); +static_assert(sizeof(i8) == (8 / 8), "Bad size"); +static_assert(sizeof(i16) == (16 / 8), "Bad size"); +static_assert(sizeof(i32) == (32 / 8), "Bad size"); +static_assert(sizeof(i64) == (64 / 8), "Bad size"); - assert(sizeof(i8) == (8 / 8)); - assert(sizeof(i16) == (16 / 8)); - assert(sizeof(i32) == (32 / 8)); - assert(sizeof(i64) == (64 / 8)); - - assert(sizeof(u8) == (8 / 8)); - assert(sizeof(u16) == (16 / 8)); - assert(sizeof(u32) == (32 / 8)); - assert(sizeof(u64) == (64 / 8)); +static_assert(sizeof(u8) == (8 / 8), "Bad size"); +static_assert(sizeof(u16) == (16 / 8), "Bad size"); +static_assert(sizeof(u32) == (32 / 8), "Bad size"); +static_assert(sizeof(u64) == (64 / 8), "Bad size"); #ifdef FLOAT_16_SUPPORT - assert(sizeof(f16) == (16 / 8)); +static_assert(sizeof(f16) == (16 / 8), "Bad size"); #endif - assert(sizeof(f32) == (32 / 8)); - assert(sizeof(f64) == (64 / 8)); - assert(sizeof(f128) == (128 / 8)); -} +static_assert(sizeof(f32) == (32 / 8), "Bad size"); +static_assert(sizeof(f64) == (64 / 8), "Bad size"); +static_assert(sizeof(f128) == (128 / 8), "Bad size"); |