Quote Originally Posted by King Mir View Post
You can prevent a typical compiler from inlining a method by calling it in a different transaction unit than it is defined.
That must be C#, specific, I've never heard of transaction units in C++.

Compilers compile one source at a time and don't look at what's in other transaction units untill linking. Since it is common practice for methods of a class to declare in their own source file, this effectively prevents non inline public and protected methods from being inlined if they are not declared as inline functions.
This is implementation specific, there are parallel compilers that compile multiple source files simultaneously and there are several commercial compilers that inline at link time. Visual Studio for one.

Quote Originally Posted by MSDN
Under The Hood: Link-time Code Generation
In the past, you could frequently get a function to be inlined by declaring it in a header file, and including that header file appropriately. This happened often with small C++ class methods such as accessor methods like get and set. However, if the back end hasn't seen the source code for a function during the current compilation run, there's no way it can inline it. Thus, functions in another source file, no matter how small, would never be inlined.
Which implies that this is no longer the case.
Quote Originally Posted by MSDN
When the linker is invoked with IL-based OBJ files, it calls COM methods in the back end (C2.DLL) to generate the final, processor-specific code. When the linker invokes the back end, it gives the back end all of the IL from all the OBJs (as well as any pregenerated code like you might find in a .LIB file.) Because the code generator now has almost perfect knowledge of the code, it can be much more aggressive when it optimizes. The primary changes you'll notice from LTCG-generated code is that many more functions are inlined, and that many functions are called without using one of the standard calling conventions. I'll drill into some of these later.
Which confirms that this is the case.