Suppose I have two source files — UndefErr.cpp:
#include <cstdio>
void UndefFunc();
void Func2(){UndefFunc();}
void Func1(){printf("Hi\n");}
And the main.cpp:
void Func1();
int main(){
Func1();
return 0;
}
As you see in the UndefErr.cpp the Func2()
going to trigger an error, for it using the undefined UndefFunc()
. However the main function doesn't care about the Func2()
! According to a relevant question I could pass an option --unresolved-symbols=ignore-in-object-files to the linker, but I want a kinda different thing. I need a linker to know if the undefined functions used somewhere, and only then fail.
The reason for asking such a strange question is that I'm trying to use a lwIP, and it is hard to understand all of its dependencies (I only need TCP/IP), and I can't find tutorials on the internet. So I thought I could compile most (or all) the .c files separately, and write some simple tests to see what it does. But this approach stumbles upon "undefined references", most of them probably irrelevant to the usecase.
void UndefFunc() {}
– Knossos