1/* @title: Static Assertions & Compile-Time Checks */
2#pragma once
3#include <compiler.h>
4#include <stddef.h>
5#include <stdint.h>
6
7#define static_assert_size(type, expected_size) \
8 _Static_assert(sizeof(type) == (expected_size), \
9 "sizeof(" #type ") != " #expected_size)
10
11#define static_assert_align(type, expected_align) \
12 _Static_assert(_Alignof(type) == (expected_align), \
13 "alignof(" #type ") != " #expected_align)
14
15#define static_assert_offset(type, member, expected_offset) \
16 _Static_assert(offsetof(type, member) == (expected_offset), \
17 "offsetof(" #type ", " #member ") != " #expected_offset)
18
19#define static_assert_disjoint_masks(mask1, mask2) \
20 _Static_assert(((mask1) & (mask2)) == 0, \
21 "masks " #mask1 " and " #mask2 " overlap")
22