Is there any specific reason why has support for designated initializers not been added to g++? Is the reason that C99 standards came late and g++ was developed earlier and
What about anonymous unions?
In C I can have this:
struct vardir_entry {
const uint16_t id;
const uint8_t sub;
const char *name;
const uint8_t type;
const union {
struct vardir_lookup lookup;
struct vardir_min_max_conf minmax;
};
const union {
const struct vardir_value_target_const const_value;
const struct vardir_value_target value;
};
};
And initialized like this:
static const struct vardir_entry _directory[]{
{ .id = 0xefef, .sub = 0, .name = "test", .type = VAR_UINT32, .minmax = { .min = 0, .max = 1000 }, .value = VARDIR_ENTRY_VALUE(struct obj, &obj, member) }
};
However under g++ even with c++14 this gives the same "sorry, unimplemented" error. We do need to be able to define C variables in C++ when we at least want to unit test C code with C++ test framework. The fact that such a valuable feature from C is not being supported is quite a shame.