I found some implementation by macro
with the help of macro I may write something like
#define DEFINE_LIST(type) \
typedef struct list_node_##type { \
struct list_node_##type *next; \
type data; \
}
int main()
{
DEFINE_LIST(int); // defines struct list_node_int
DEFINE_LIST(double); // defines struct list_node_double
IMPLEMENT_LIST_INSERT(int); // defines list_int_insert
IMPLEMENT_LIST_INSERT(double); // defines list_double_insert
return 0;
}
looks like c could make generic programming come true but it could be very tedious
and much more harder to maintain than template
Do you have any ideas to make it more easy to read and maintain by pure C?
Thank you very much