#include #include #define KIND int kind; #define example_kind 1 typedef struct { KIND } value_t; typedef struct { KIND int foo; } example_t; int main() { value_t *value = (value_t *)malloc(sizeof(example_t)); ((example_t *)value)->kind = example_kind; ((example_t *)value)->foo = 42; switch (value->kind) { case example_kind: printf("example_t with foo=%d\n", ((example_t *)value)->foo); break; default: printf("unknown value kind\n"); } return 0; }