[cfe-dev] cross compilation unit inline?

Jonny Yu yingshen.yu at gmail.com
Thu Dec 1 16:41:12 PST 2011


I know this is not supported in traditional linker.
But is this supported after enabling LTO?
My experiment with Xcode 4.2 seems the answer is no, but I'd bring up to confirm.
Specifically, I mean the sample code below,

=TestClass.h=
class A {
public:
void foo ();
}
=TestClass.cpp=
inline void A::foo() {
   // short code
}
=Main.cpp=
#include "TestClass.h"
void main() {
    A a;
    a.foo();
}

The situation is C++ FAQ recommend putting inline in cpp file is best practice to hide implementation details, and MSVC can build the above code by enabling LTCG. Porting this codebase to LLVM+clang seems I have to either expose inline functions or remove inline keyword. I still need build the same codebase on MSVC, so that's not ideal.

Any comments are appreciated.

Thanks!

-Jonny



More information about the cfe-dev mailing list