For my upcoming C university project, I am invited to have a modular code that allows C. In principle, I will have a .c file and a corresponding .h file for some data structure, such as a linked list, binary tree, hash table, whatever .. .
Using the linked list as an example, I have the following:
typedef struct sLinkedList { int value; struct sLinkedList *next; } List;
But this forces value be of type int , and a user using this linked list library will be forced to directly modify the source code of the library. I want to avoid this, I want to avoid the need to change the library to make the code as modular as possible.
My project might need a linked list for a list of integers, or maybe a list of some structure. But I'm not going to duplicate library files / code and change the code accordingly.
How can i solve this?
source share