STATICINLINE | NOSTATICINLINE (C++ only)

Category

Language element control

Pragma equivalent

None.

Purpose

Controls whether inline functions are treated as having static or extern linkage.

When NOSTATICINLINE is in effect, the compiler treats inline functions as extern: only one function body is generated for a function marked with the inline function specifier, regardless of how many definitions of the same function appear in different source files. When STATICINLINE is in effect, the compiler treats inline functions as having static linkage: a separate function body is generated for each definition in a different source file of the same function marked with the inline function specifier.

Syntax

Read syntax diagramSkip visual syntax diagram
   .-NOSTATICI-.   
>>-+-STATICI---+-----------------------------------------------><

Defaults

NOSTATICINLINE

Predefined macros

None.

Examples

Using the STATICINLINE option causes function f in the following declaration to be treated as static, even though it is not explicitly declared as such. A separate function body is created for each definition of the function. Note that this can lead to a substantial increase in code size.
inline void f() {/*...*/};

Using the NOSTATICINLINE compiler option gives f external linkage.