From a02e91bfa3d758b29b379376f36320b06fc217de Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Tue, 3 May 2022 02:55:38 +0300 Subject: [PATCH] define macros for struct members declaration --- struct.c | 12 ++---------- struct.h | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/struct.c b/struct.c index 0780756..aea7ba6 100644 --- a/struct.c +++ b/struct.c @@ -1,16 +1,8 @@ #include "struct.h" -struct cu_value_s test_struct[] = { - {.type = Sequence, .sequence = {.size = 6}}, - {.type = Array, .array = {.item = 4, .count = 12, .index = 0}}, - {.type = Int16}, - {.type = Array, .array = {.item = 14, .count = 3, .index = 1}}, - {.type = NoValue} -}; - -/*CU_STRUCT_BEGIN(test) +CU_STRUCT_BEGIN(test) CU_VALUE_SEQUENCE(6) CU_VALUE_ARRAY(4, 12) CU_VALUE_INT16() CU_VALUE_ARRAY_INDEX(14, 3) -CU_STRUCT_END()*/ +CU_STRUCT_END() diff --git a/struct.h b/struct.h index 6d5399b..2db2840 100644 --- a/struct.h +++ b/struct.h @@ -36,7 +36,7 @@ struct cu_value_s { #define CU_VALUE_INT32() {.type = Int32}, #define CU_VALUE_INT64() {.type = Int64}, #define CU_VALUE_SEQUENCE(_size) \ - {.type = Sequence, .sequence = {.size = (_size)}, + {.type = Sequence, .sequence = {.size = (_size)}}, #define CU_VALUE_ARRAY(_item, _count) \ {.type = Array, .array = {.item = (_item), .count = (_count), .index = 0}}, #define CU_VALUE_ARRAY_INDEX(_item, _index) \