C is not C++, so we cannot use template of C++ to achieve this.
There're more than one way to achieve this. For example, define ListItem with void* pointer.
struct ListItem{struct ListItem *next;struct ListItem *prior;void* data;
}
In this way, we are thinking from data structure's perspective, not from user's perspective.
Another example, define all operations of LinkedList using macro.
#define LIST_HEADER(atype) atype *prior; atype *next
#define LIST_ADD(head,elem) ...
#define LIST_DE......
阅读全文