I have defined list_t
in my project that got list module API like list_pop()
. But now I have to use MySQL lib to communicate with DB, but the MySQL lib still got its list implements, and also defined a list_pop()
API. In my other modules, I have to link both of them, and comes the conflict.
One of my solution is, separately include header file for different list API calling, this works well, but while some function need to call both of MySQL::list_pop()
and local::list_pop()
, how to notify the compiler the correct link point? Is there some GCC trick that can do these without any changes to local::list_pop()
?
For most practical purposes, you are going to have to rename one or the other set of functions. It is probably easier to rename your own than those of MySQL.
The simplest approach is to simply add a prefix that has a higher probability of being unique (enough), such as your initials, or the codename of your project, or something. Or you can rename everything to avoid collisions, being aware that MySQL might add a new function in the future.
This is exactly why namespaces were invented for C++, and why C projects usually have systematic prefixes on sets of functions.