Given:
file1.hxx:
inline void Func();
file1.cxx:
void Func() { beep(); }
main.cxx
#include "file1.hxx"
main()
{
Func();
}
GCC quite understandably emits the warning “warning: inline function ‘Func()’ used but never defined.” when compiling main.cxx. Two questions:
- When linking with LTO, does the linker resolve that call, whether it chooses to inline or not? I read about a function attribute that says to emit the function into the object file, even if all instances have been inlined. Would that affect this? Is there any way to get the linker to fix this?
- If not, then why is that a warning, not an error?
Note that I’m not asking how to rearrange this code to make it compile clean. I’m quite well aware of the C++ specs restriction on inline and translation units. What I’m asking is if there is a way to get GCC to go beyond the spec and make this work, especially given that the spec doesn’t require any particular behavior of link time optimizations.