I tried to prove that you need a function definition inlinein all TUs that use it. However, the following code compiles well (MSVS 2010):
inc.h
inline void foo();
test.cpp
#include "inc.h"
void x();
int main()
{
foo();
x();
return 0;
}
void foo()
{
}
test2.cpp
#include "inc.h"
void x()
{
foo();
}
Note that function calls exist to prevent optimization. It compiles, although it is foodeclared inlineand defined only in test.cpp, but is also used in test2.cpp.
If I comment on the call fooin main(), I get the expected error.
"void __cdecl foo (void)" (? foo @@ YAXXZ) referenced by the function "void __cdecl x (void)" (? x @@ YAXXZ) fatal error LNK1120: 1 unresolved external
foo ? , ?
extern foo inc.h ( foo main).