How to create an enum dynamically in compiling time for my struct
问题 I have this struct below struct foo { char *name; int (*validate)(u8_t *data, size_t size); u8_t value; u8_t changed; foo_id id; }; typedef struct foo foo_t; I wish I to create an array of foo_t in compiling time through defines, like this: int my_validate(u8_t *data, size_t size) {...} FOO_CREATE(my_name, my_validate, 0, 0); FOO_CREATE(my_name2, NULL, 0, 0); and in compiling time the result be: enum { MY_NAME_FOO = 0, MY_NAME2_FOO, FOO_COUNT } foo_id; static foo_t foo[FOO_COUNT] = { { .name