Sun Studio 12: C User's Guide

D.1.10 inline Functions

6.7.4 Function specifiers

The C99 function-specifier inline has been added. inline is fully functional for functions with both internal and external linkage. Inline function definitions and extern inline functions now work as specified by the 1999 C ISO standard.

An inline function definition is a function defined with the keyword inline, and without either the keywords static or extern, and all prototypes appearing within the source (or included files) also contain the keyword inline without either the keywords static or extern.

An inline function definition does not provide an external definition for the function. Any function call appearing in the source file containing an inline definition will either be satisfied by inlining the function definition at the call site, or by a reference to an externally defined function.

The compiler will inline calls to inline definitions only when optimizing and only when the compiler optimizer believes it is profitable to do so. Otherwise a call to an external function will be made. Therefore any program containing inline definitions should link with an object file containing an extern function definition.

Use of both the keywords extern and inline with a function definition (or on any prototype in the file continuing the function definition) will result in an external function being defined in that object file. To be compatible with C++ linking with objects that contain multiple definitions of extern inline functions will result in the linker choosing just one of these functions to satisfy any external references.

To get standard conforming behavior, old code must be recompiled using the current compiler. However, if you have instances of extern inline function definitions in old C and C++ binaries (pre C/C++ 5.6) and you wish to link those binaries with new C and C++ binaries without changing the behavior of the old binaries, specify -features=no%extinl.