Originally Posted by
King Mir
Compilers are/were generally designed to compile each source file separately. With this practice, it is impossible for a compiler to inline a function that written in a different source file. The solution: have potential inline candidates be included in header files. The problem with that is multiple definition errors. So the inline key word was invented to allow multiple definitions for functions intended to be inlined.
People say that gcc is smart about figuring out which functions to inline, as far as I can tell, it cannot possibly inline a function unless a) it is declared inline, and included in a header, or b) it is declared in the source file unit that it is used in. Basically it boils down to a gcc can't inline a function call if the function being called is not included in the same compilation unit.