I’m trying to add some additional functionality to an API. However, I’d like these additional functions to be in an external library of mine and not mixed with the original library’s code.
The problem comes when I need to access static functions of the mentioned API from my functions. Of course I can’t, so the only solution I see is either to copy these functions’ code into my API or to make them non-static in the original API. Both are not too good options for me for obvious reasons.
More precisely:
original_api.c
void some_function() -> uses some_helper_function()
static some_helper_function()
my_api_extension.c
void some_extended_function() -> needs to use some_helper_function from original_api.c, but can't
Could you suggest which would be the most flexible way to handle this?
I’d like to point out that it’s related to C only, not C++.
structwith pointers to these functions. Declare it in a separate#includefile, available to the extension, but not to the entire world.structin your extension.Something like this: