Suppose we have some static library Library that has some function void x() { foo(); } (let's say, declared in library.h and defined in library.cpp)
The definition void foo(); is in some header file functionality.h.
Furthermore, when we're building Library.lib, we define _BUILDING_LIBRARY (with -DBUILDING_LIBRARY or by whatever means).
Then suppose functionality.cpp looks like this:
#ifdef _BUILDING_LIBRARY
void foo() { do_x(); }
#else
void foo() { do_y(); }
#endif
The question is as follows:
How do I get a project that includes Library and calls x(), but also builds the file functionality.cpp (without _BUILDING_LIBRARY) to pick the desired implementation of foo()?
#include <library.h>
#include <functionality.h>
int main()
{
    x();
    foo();
}
Should execute
do_x();
do_y();
However, a minimal working example shows both calls execute do_y
Someone suggested that this question might give me an answer, but that would mean that Library would provide me with foo() as well (which I don't need nor want, I only need x() from Library).