4.27 Inline functions in C++ and C90 mode

The inline keyword is not available in C90. The effect of __inline in C90, and __inline and inline in C++, is identical.

When declaring an extern function to be inline, you must define it in every translation unit that it is used in. You must ensure that you use the same definition in each translation unit.
The requirement of defining the function in every translation unit applies even though it has external linkage.
If an inline function is used by more than one translation unit, its definition is typically placed in a header file.
ARM does not recommend placing definitions of non-inline functions in header files, because this can result in the creation of a separate function in each translation unit. If the non-inline function is an extern function, this leads to duplicate symbols at link time. If the non-inline function is static, this can lead to unwanted code duplication.
Member functions defined within a C++ structure, class, or union declaration, are implicitly inline. They are treated as if they are declared with the inline or __inline keyword.
Inline functions have extern linkage unless they are explicitly declared static. If an inline function is declared to be static, any out-of-line copies of the function must be unique to their translation unit, so declaring an inline function to be static could lead to unwanted code duplication.
The compiler generates a regular call to an out-of-line copy of a function when it cannot inline the function, and when it decides not to inline it.
The requirement of defining a function in every translation unit it is used in means that the compiler is not required to emit out-of-line copies of all extern inline functions. When the compiler does emit out-of-line copies of an extern inline function, it uses Common Groups, so that the linker eliminates duplicates, keeping at most one copy in the same out-of-line function from different object files.
Related concepts
4.20 Inline functions
4.21 Compiler decisions on function inlining
4.22 Automatic function inlining and static functions
4.23 Inline functions and removal of unused out-of-line functions at link time
4.24 Automatic function inlining and multifile compilation
4.26 Compiler modes and inline functions
4.28 Inline functions in C99 mode
4.29 Inline functions and debugging
Related reference
4.25 Restriction on overriding compiler decisions about function inlining
7.87 --inline, --no_inline
9.8 __inline
Related information
Elimination of common groups or sections
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.