C ++ Built-in Performance Methods

I was told that to create short functions / methods that are often called built-in using the inline keyword and writing the body in the header file. This was to optimize the code, so there would be no overhead for the actual function call.

What does it look like today? Do modern compilers (Visual Studio 2010 in this case) build such short functions automatically or is it still "necessary" to do it yourself?

+5
source share
7 answers

inlinehas always been a hint to the compiler, and these days, most compilers make their own decisions in this regard (see register).

inline, . , , : - , , .

, , , . , inline, , , . (, , static, )

+7

, inline , "" , . , , .

, non-inline, , .

+3

C4710, , , , .

C4711, , , inlining.

, , , , .

+3

:

  • inline

    • , ;
    • , . MSDN

      inline , .
      .

  • __forceinline ( __ attribute __((always_inline)) gcc). .

    __forceinline / .

  • Microsoft - , , /GL /LTCG . : , /LTCG.

, , :

  • ;
  • .
+2

, ( ) , ( ) . inline .

+1

( ), , .

+1

All Articles