This might seem like an odd question, but I was wondering if it were possible with any sort of hack to call static functions from another file without explicitly using extern or anything like that. Perhaps by calling the memory address of the function directly or something.
Basically what I want to do is create a test framework which can call into any function by specifying the function, file and function parameters.
So something like this structure:
component/
component.c
static int foo(int a){return a/2;}
int bar(){ return 4;}
unit_tests/
main.c
int val = component.c::foo(4) * bar();
Even better would be if I could do this at runtime by injecting into the memory address of the function or something. I'm not entirely sure about if this would be executable on linux though, or if I'd hit security issues.
Perhaps something similar to this, and have a block of code in my component process to interpret runtime calls and translate to the correct function address: Calling a function through its address in memory in c / c++