@floooh Do you have recommendations for tagged unions in C API?

I have a case in skribidi (styling https://github.com/memononen/Skribidi/issues/49#issuecomment-2973298601) which is a good fit for tagged union.

I did see that you reverted some union use in Sokol in a "bindgen preparations" CL way back in 2020. Smells like a minefield for language interop?

In my case I would be fine having a function for initializing the whole struct, or having a getter function to poke the specific struct out. Sort of opaque value struct :)

Text underline support · Issue #49 · memononen/Skribidi

It would be nice if skribidi supports text underline (and I guess strikethrough would be a trivial addition if underline already exists ...)

GitHub

@MikkoMononen I actually want to do something similar to tagged unions soon in the sokol_gfx.h API, but without the 'union part':

https://github.com/floooh/sokol/issues/1252

...it looks like tagged unions but is simply different nested structs side by side, but only one of those would be 'active'.

The active nested struct would be identified by one of the nested struct members (for instance the buffer/image item)

Planning: Introduce a resource view object type? · Issue #1252 · floooh/sokol

Just to get this out of my head for now: Currently sokol-gfx implicitely manages resource-view objects in some backends, this simplifies the sokol-gfx API but limits flexibility, and especially wit...

GitHub

@floooh That looks simple indeed! I like how that does not require the tag or flag.

In my case the union version is like 24B and everything spelled out is 128B. One one hand I could make things a bit more restricted, and just allow one spelled out version, or I could make things flexible and have the tagged union, and some more memory being used.

Sometimes I like these riddles, sometimes I dont :)