What’s the usual way to handle a few platform specific functions in a portable C library?
I’m working on a small portable C library where only about five functions need to be implemented differently depending on the platform or the user’s needs. Three of them need to be overridden, while the other two could have weak default implementations.
At the moment I’m defining them as weak symbols and letting the application provide strong implementations. For such a small number of hooks, this seems convenient and keeps the API simple. I can see now that it’s not very obvious to the user that some of these functions are expected to be overridden.
Is using weak symbols like this a reasonable approach for a portable C library, or would something like a struct containing function pointers be more idiomatic? What is recommended?