Is there a common practice of extending API C while maintaining compatibility with it?
Suppose I want to provide the foo function in the c library:
foo(int value);
Now in a later version, I would like to extend foo to allow another parameter.
foo(int value, const char *description_may_be_NULL);
To provide advanced compatibility, I would name the new one differently, for example. foo2.
It would be wise to provide a macro to:
#define MYLIB_API 2
#include <mylib.h>
This would avoid the use of bad names in practice.
Are there any common methods for handling conflicting advanced compatibility and elegant code for future versions? Any examples of how popular C APIs have handled in the past will be appreciated.
: , : foo(int) , varargs/struct API. , , . , -, .