Nice system built with only a couple of C99 macros. That small header also achieves matching for specific C types over the "sum types".
In the context of C99, isn't tagged union the more usual name instead of sum type?
In the context of C99, isn't tagged union the more usual name instead of sum type?
Take one of the most basic sum types in Haskell's base library, Maybe:
data Maybe a = Nothing | Just a
This simple construction gives you the ability to write functions over optional values and avoid the issues with null pointers. This would be an amazing feature to have in C but it can't be achieved due to C's very limited type system.