aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/stddef.c
blob: f63e57c4e22ba8ec13966be8e58a756839b4b46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <helpers.h>
#include <stddef.h>

struct S {
    int x;
    int y;
};
struct T {
    char a;
    int b;
    char c;
};

int main() {
    ASSERT_EQ(0, offsetof(struct S, x));
    ASSERT_EQ(4, offsetof(struct S, y));
    ASSERT_EQ(0, offsetof(struct T, a));
    ASSERT_EQ(4, offsetof(struct T, b));
    ASSERT_EQ(8, offsetof(struct T, c));

    char buf[offsetof(struct T, b)];
    ASSERT_EQ(4, sizeof(buf));
}