How can I do this in a smarter way in regular C-programming, without having an init function that initializes the values?
struct myStruct_s {
int myInt;
Bool_t myBool;
EventCallback_t myEventCallback;
};
#define DESIRED_ARRAY_SIZE (5)
static struct myStruct_s myArray[] = {
#if 1 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 2 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 3 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 4 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 5 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 6 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 7 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 8 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 9 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 10 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 11 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 12 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 13 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 14 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 15 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 16 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 17 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 18 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 19 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 20 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
};
modified 6-Apr-18 7:29am.
|