-
Notifications
You must be signed in to change notification settings - Fork 373
Add a feature to simplify enums used as tagged unions #353
Description
When enum variants contain data, they will be converted to a tagged union in C.
The variants will be converted to new types with complicated long names.
In cases, where the enum variants only contain a single field, it seems preferable not to define new types for the fields of the untagged union in the C struct, representing the tagged union, but just use the single field types.
An example, where this causes unnecessary structs, is wgpu.
I just described in this issue, how I'd prefer the C code to look like.
Since I don't see a reason to have single value wrapper structs in a C binding, I'd prefer it to just use the existing types by default in this case.
But I can also think of configuration options for enums.
For consistency reasons it may be more reasonable to always create a new type, except the specific option is set.