I have some structures and corresponding functions that operate on them written in their own header and c file.
I wondered if it was possible to create a new header and c file for code that would "inherit" those particular types and functions with a new appropriatly descriptive declaration? Is it possible to typedef functions and structs in this manner in order to reuse the code?
I have looked into function pointers but I am not sure if this is the correct tool to achieve what I am after. I guess one other option is to refactor the code so that the names are generic.
Code example:
// function1.h typedef struct src_data { ... } src_data; src_data* process_src_data(...) { ... return new_data; } // function2.h #include "function1.h" typedef src_data dest_data; typedef dest_data* (*process_dest)(void); process_dest process_dest_data = &process_src_data; usage would then be as follows:
#include "function1.h" #include "function2.h" src_data *sourceData = process_src_data(...); dest_data *destinationData = process_dest_data(...);