My C library has some optional features, and using automake, the user can turn them on and off by providing flags to configure.
If a feature is turned off, that function will not be compiled.
However, my question is, should I also remove the function prototype from the public headers in that case?
It seems like not a good idea to have function prototypes for functions that are not compiled, but it also seems to me not a good idea to have different public headers installed depending on the library configuration. (Similar to how it's bad practice to install config.h
in the public headers directory.)
What's the best approach for public headers when it comes to optional features? If a user tries to use a disabled feature, should the error come at compile time, or link time? There must be a standard practise for this situation. (I prefer to comply with GNU coding standards if there are multiple ideas, but I don't know of the GNU standard on this issue.)