Let's say I have have the following files in C++:
// bar.hpp
int foo();
int bar();
// bar.cpp
#include "bar.hpp"
int bar() { return 3; }
// main.cpp
#include "bar.hpp"
int main() { return bar(); }
Note that foo() was declared (in both main.cpp and bar.cpp translation units) but never defined anywhere. On the other hand, it wasn't used anywhere either. Is this legal? I suspect it's fine in practice because neither compiled unit refers to the foo symbol so the linker will never try to find it. But I'm curious about whether the C++ standard guarantees that this is OK. (I'm not even sure that the standard talks about linking.)