diff options
Diffstat (limited to 'misc/examples/new_vec.c')
| -rw-r--r-- | misc/examples/new_vec.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/misc/examples/new_vec.c b/misc/examples/new_vec.c index df443b7f..88efd55a 100644 --- a/misc/examples/new_vec.c +++ b/misc/examples/new_vec.c @@ -4,32 +4,33 @@ forward_cvec(cvec_i32, int); forward_cvec(cvec_pnt, struct Point); -struct MyStruct { +typedef struct MyStruct { cvec_i32 intvec; cvec_pnt pntvec; -} typedef MyStruct; +} MyStruct; -#define i_val int -#define i_is_forward +#define i_key int #define i_tag i32 +#define i_is_forward #include <stc/cvec.h> typedef struct Point { int x, y; } Point; -#define i_val Point +#define i_key Point +#define i_tag pnt #define i_less(a, b) a->x < b->x || (a->x == b->x && a->y < b->y) +#define i_eq(a, b) a->x == b->x && a->y == b->y #define i_is_forward -#define i_tag pnt #include <stc/cvec.h> -int main() +int main(void) { MyStruct my = {0}; - cvec_pnt_push(&my.pntvec, (Point){42, 14}); - cvec_pnt_push(&my.pntvec, (Point){32, 94}); - cvec_pnt_push(&my.pntvec, (Point){62, 81}); - cvec_pnt_push(&my.pntvec, (Point){32, 91}); + cvec_pnt_push(&my.pntvec, c_LITERAL(Point){42, 14}); + cvec_pnt_push(&my.pntvec, c_LITERAL(Point){32, 94}); + cvec_pnt_push(&my.pntvec, c_LITERAL(Point){62, 81}); + cvec_pnt_push(&my.pntvec, c_LITERAL(Point){32, 91}); cvec_pnt_sort(&my.pntvec); |
