Keil Logo Arm Logo

Extern inline functions

Extern inline functions

The ISO C++ Standard requires inline functions to be defined wherever you use them. To prevent the clashing of multiple out-of-line copies of inline functions, the C++ compiler emits out-of-line extern functions in common sections.

Show/hideOut-of-line inline functions

The compiler emits inline functions out-of-line, in the following cases:

  • The address of the function is taken, for example:

    inline int g()
    {
        return 1;
    }
    int (*fp)() = &g;
    
  • The function cannot be inlined, for example, a recursive function:

    inline unsigned int fact(unsigned int n) {
        return n < 2 ? 1 : n * fact(n - 1);
    }
    
  • The heuristic used by the compiler decides that it is better not to inline the function. This heuristic is influenced by -Ospace and -Otime. If you use -Otime, the compiler inlines more functions. You can override this heuristic by declaring a function with __forceinline. For example:

    __forceinline int g()
    {
        return 1;
    }
    

    See also --forceinline for more information.

Copyright © 2007-2008, 2011-2012 ARM. All rights reserved.ARM DUI 0376D
Non-ConfidentialID062912

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings