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