ABI compatibility: unions
Recently we've been adding unions in our public API:
struct di_edid_detailed_timing_def {
/* Pixel clock */
int32_t pixel_clock_hz;
…
union {
/* Flags for ANALOG_COMPOSITE signals */
struct {
…
} analog_composite;
/* Flags for BIPOLAR_ANALOG_COMPOSITE signals */
struct {
…
} bipolar_analog_composite;
…
};
};
Is that really all right when it comes to ABI compatibility and future extensibility? What happens if we want to add a new top-level field in struct di_edid_detailed_timing_def
? What happens if we add it after the union
field, then need to add a new field into the embedded di_edid_detailed_timing_def.analog_composite
struct itself?
Edited by Simon Ser