I have a constant array that comes from a define that I cannot modify.
#define MY_ARRAY {1,11,111,2,22,222,3,33,333}
#define SIZE 3
I want to assign this array to a const struct array
// EDIT : Added mixed sizes to show there might be a padding problem as well
struct foo {
uint8_t val1;
uint32_t val2;
uint32_t val3;
}
const struct foo my_foo[SIZE] = MY_ARRAY;
But my compiler complains about missing braces around initializer. It expects something alongs the lines of :
const struct foo my_foo[SIZE] = {{1,11,111},{2,22,222},{3,33,333}};
I would need some kind of typecast but I can't make it work
I tried this :
const struct foo my_foo[SIZE] = (const struct foo[SIZE]) MY_ARRAY;
But I get the same warning