Dann Corbit wrote:mathmoi wrote:Tord Romstad wrote:Sven Sch?le wrote:Putting inline implementations into .h files instead, not .cpp files, will work.
I suspect that GCC would complain that the same function in multiple source files in that case (I haven't tried, though). Perhaps defining the functions as 'static inline' and placing them in .h files would work.
Tord
Hi Tord,
In fact inline function must be implemented in the .h file. The compiler will not complain. Since the function is inlined it's definition must be know while compiling a call to it, this is why you must put the definition of the function in the header file. Otherwise inline is ignored
Strangely, most other compilers get it right (MS, Intel, Compaq, etc.)
There is no reason that the compiler cannot rearrange things to its liking.
The GCC design is just lazy.
It is not supposed to cause problems if the implementations of an inline function is not written in the header files. It will just not be inlined.