I have two static libraries (say A and B) and both of them reference an identical third party library (say C) by including the source files directly and independently. C is pretty simple and only have one .h and .c files. Executable D links with A and B.
Let's assume there is a function fn
in C. When executable D resolves the function name: fn
, it picks arbitrary fn
implementation within either A or B.
My question is how to make sure the codes within A references the A's C implementation and B references B's C implementation?
As C is a third party library, so I'd not modify C's codes. So renaming either one of functions doesn't work. I ever consider uses namespace of C++ that wrap C's code like following
namespace WRAP
{
#include "moudule_c_source_file.c"
}
However, as module_c_souce_file.c includes module_c_source_file.h which contains extern "C"
declare. This causes the generated symbol object file doesn't contains namespace information. So that executable D still links arbitrary function implementation.
Any idea of resolving my question mentioned above without touching the third party library codes?