Derive-C
Loading...
Searching...
No Matches
derives.c
Go to the documentation of this file.
1
#include <assert.h>
2
3
#include <
derive-c/derives/clone.h
>
4
#include <
derive-c/derives/eq.h
>
5
#include <
derive-c/derives/ord.h
>
6
#include <
derive-c/derives/std.h
>
7
#include <
derive-c/derives/struct.h
>
8
9
#define Foo_REFLECT(F) \
10
F(uint32_t, bing) \
11
F(char, baz) \
12
F(double, zing)
13
14
DERIVE_STRUCT
(Foo)
15
DERIVE_EQ
(Foo)
16
DERIVE_CLONE
(Foo)
17
DERIVE_ORD
(Foo)
18
19
int
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
}
clone.h
DERIVE_CLONE
#define DERIVE_CLONE(ID)
Definition
clone.h:13
main
int main()
Definition
employees.c:106
eq.h
DERIVE_EQ
#define DERIVE_EQ(ID)
Definition
eq.h:6
ord.h
DERIVE_ORD
#define DERIVE_ORD(ID)
Definition
ord.h:7
std.h
struct.h
DERIVE_STRUCT
#define DERIVE_STRUCT(ID)
Definition
struct.h:13
examples
derives
derives.c
Generated by
1.13.2