I have a structure that contains arrays of another structure, it looks something like this:
typedef struct bla Bla;
typedef struct point Point;
struct point
{
int x, y;
};
struct bla
{
int another_var;
Point *foo;
};
Now I want to initialize them in a global area. They are intended to describe the module. I tried to do this with c99 complex literals, but the compiler (gcc) didn't like this:
Bla test =
{
0, (Point[]) {(Point){1, 2}, (Point){3, 4}}
};
I get the following errors:
error: initializer element is not constant
error: (near initialization for 'test')
Since I donβt need to change it, I can put as much βconstβ in it as necessary. Is there any way to compile it?
source
share