i'm trying to create an alias for a variable inside a struct like this:
typedef struct {
union {
Vector2 position;
float x, y;
};
union {
Vector2 size;
float width, height;
};
} RectangleF;
(note that i didn't name the unions so i dont have to write: 'variable.unionname.x' etc.)
however i get a "Initializer overrides prior initialization of this subobject" warning when i create some constants of this struct:
static const RectangleF RectangleFZero = {
.x = 0.0f,
.y = 0.0f, // warning
.width = 0.0f,
.height = 0.0f // warning
}
is there anything wrong doing this? and if not, how can i get rid of this warning?
Edit: Solution i use now:
typedef struct {
union {
Vector2 position;
struct { float x, y; };
};
union {
Vector2 size;
struct { float width, height; };
};
} RectangleF;