Suppose I have such code:
lib.h:
void func();
lib.cpp:
void __attribute__((weak)) func()
{
printf("original");
}
and these code would be compile into libA.a
.
clang++ lib.cpp -o libA.a
Then in my test unit I want to override this func
function such as:
test.cpp:
#include "lib.h"
void func()
{
printf("override");
}
And:
clang++ test.cpp -lA
But in my result the output is always original
.
What is the right way to weak
a static lib function and then override it externally?