I copied some examples of how to implement variadic macros, and expanded on that for C basic types. It mostly worked, you'll always have difficulty for corner cases like separating pointers and arrays, but it worked well for the basic C types.
I gave up for a few reasons:
- I wanted a form to register new types, so it could work for user-defined types;
- the C pre-processor knows nothing about lists that can be expanded multiple times;
- variadic C macros are ugly hacks.
Maybe one day I'll get back to it and publish it.The interesting part is that _Generic combined with macros allows some very interesting tools for implementing primitive forms of polymorphism. Actually, if the C pre-processor supported lists, it would be possible to implement RTTI in C.