Derive-C
Loading...
Searching...
No Matches
derives.c
Go to the documentation of this file.
1#include <assert.h>
2#include <stdint.h>
3
9
10#define Foo_REFLECT(F) \
11 F(uint32_t, bing) \
12 F(char, baz) \
13 F(double, zing)
14
16DERIVE_EQ(Foo)
17DERIVE_CLONE(Foo)
18DERIVE_ORD(Foo)
19
20int main() {
21 Foo f = {.bing = 23, .baz = 'c', .zing = 3.14};
22 Foo g = {.bing = 23, .baz = 'c', .zing = 3.14};
23
24 assert(Foo_eq(&f, &g));
25 assert(!Foo_gt(&f, &g) && !Foo_lt(&f, &g));
26
27 Foo z = Foo_clone(&f);
28 z.bing += 10;
29 assert(Foo_gt(&z, &f));
30}
#define DERIVE_CLONE(ID)
Definition clone.h:13
#define DERIVE_EQ(ID)
Definition eq.h:6
#define DERIVE_ORD(ID)
Definition ord.h:7
int main()
Definition staticbump.c:44
#define DERIVE_STRUCT(ID)
Definition struct.h:13