I Write Type Safe Generic Data Structures in C
June 25, 2025・7 minute read I write type safe generic data structures in C using a technique that I haven’t seen elsewhere. It involves unions and typeof , but we’ll get to that. My approach works for any type of data structure: maps, arrays, binary trees… but for this article I illustrate the ideas by implementing a basic linked list. Since many people aren’t aware you can do C generics at all, I figured I’d start simple and build up to this: typedef struct { int value ; } Foo ; List ( int )