I have the following code:
#define SUB_LIST 1, 2, 3
uint8_t sub_array[] = {SUB_LIST};
#define SUB_LIST_SIZE (sizeof(sub_array) / sizeof(sub_array[0]))
uint8_t array[SUB_LIST_SIZE + X] = {0};
Here, sub_array[]
exists only because I need it to get the number of elements in SUB_LIST
. It is not used anywhere else, and thus it is quite a waste of memory.
It is possible to get the number of element in SUB_LIST
without having to permanently allocate memory for sub_array[]
?