This is just another interview question.
Can we have a linked list of different data types, i.e. each element in a linked list can have different structure or union
I use these macros I wrote to make general linked lists. You just create your own struct and use the macro list_link
somewhere as a member of the struct. Give that macro one argument naming the struct (without the struct
keyword). This implements a doubly linked list without a dummy node (e.g. last node links back around to first node). The anchor is a pointer to the first node which starts out initialized by list_init(anchor)
by giving it the lvalue (a dereferenced pointer to it is an lvalue). Then you can use the other macros in the header. Read the source for comments about each available macro functions. This is implemented 100% in macros.
http://phil.ipal.org/pre-release/list-0.0.5.tar.bz2