Type-safe generic containers with macros
问题 I'm trying to make a type-safe generic linked list in C using macros. It should work similarly to how templates work in C++. For example, LIST(int) *list = LIST_CREATE(int); My first attempt was for #define LIST(TYPE) (the macro I used above) to define a struct _List_##TYPE {...} . That, however, did not work because the struct would be redefined every time I declared a new list. I remedied the problem by doing this: /* You would first have to use this macro, which will define the `struct