Using anonymous union
, we can get address without such warning:
#pragma pack(push, 4)
typedef struct {
union {
int a;
char a_addr[sizeof(int)];
};
union {
double b;
char b_addr[sizeof(double)];
};
} my_t;
#pragma pack(pop)
use it as this: &my.b_addr
.