> Hi Carl,
>
> I think it is possible to write the inline function implementation in
> the CPP file, and it will usually be OK.
Only if the function is only called from within that file.
> But in some cases, like templates, the inline will not work.
It will if the template is only used in that file - template are really no
different from ordinary inline functions in this case.
> Personally I'm using the inline only at the H file, but some college
> of mine need to convince, and I do not remember the convincing
[quoted text clipped - 3 lines]
> implementation in the CPP is causing trouble. And the more examples
> the more convincing I will be.
The cases where it doesn't work should be pretty convincing.
// A.h
inline void f();
// A.cpp
#include "A.h"
inline void f()
{
}
// B.cpp
#include "A.h"
void foo()
{
f(); // linker error
}
-cd
Dirk - 27 Nov 2004 22:34 GMT
What about link time optimization, Carl? I thought this way a function from
another object file can be inlined.
>> Hi Carl,
>>
[quoted text clipped - 40 lines]
>
> -cd
Carl Daniel [VC++ MVP] - 28 Nov 2004 01:16 GMT
> What about link time optimization, Carl? I thought this way a
> function from another object file can be inlined.
It can. But that involves an optimization for functions that are not
declared inline, ironically enough! The basic link must first succeed
before cross module inlining is even considered.
-cd