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