[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Inlining

The compiler determines whether to inline a function based on the settings of the ANSI Keywords Only item, and the Inline Depth, Auto-inline, and Deferred Inlining items in the C/C++ Language Panel.

For beginners

When you call an inlined function, the compiler inserts the function's instructions instead of a call to that function. Inlining functions makes your programs faster (because you execute the function's code immediately without a function call and return), but possibly larger (because the function's instructions may be repeated in several different places in your program).

If you turn off the ANSI Keywords Only option, you can declare C functions to be inline. The inlining items in the C/C++ Language Panel let you choose to inline no functions, only functions declared inline, or all small functions as shown in Table 3.2.

This option
Does this
Don't Inline  
Inlines no functions, not even C or C++ functions declared inline.  
Smart  
Inlines small functions to a depth of 2 to 4 inline functions deep.  
1 to 8  
Always inlines to the depth specified by the numerical selection.  
Always Inline  
Always inlines functions, no matter the depth.  

Options for the Inline Depth pop-up menu:

The Smart item and items 1 to 8 in the Inline Depth pop-up menu correspond to the pragma inline_depth ("C/C++ Language Panel"). To check whether this option is on, use __option(inline_depth), described at "Checking Options".

The Don't Inline item in the Inline Depth pop-up menu corresponds to the pragma dont_inline, described at "dont_inline." To check whether this option is on, use __option (dont_inline), described at "dont_inline." By default, this option is off.

The Auto-Inline option lets the compiler choose which functions to inline. Also inlines C++ functions declared inline and member functions defined within a class declaration. This option corresponds to the pragma auto_inline, described at "auto_inline." To check whether this option is on, use __option (auto_inline), described at "auto_inline." By default, this option is off.

The Deferred Inlining option tells the compiler to inline functions that have not been defined yet. This option corresponds to the pragma auto_inline, described at "defer_codegen." To check whether this option is on, use __option (defer_codegen), described at "defer_codegen."

With Deferred Inlining on, the compiler uses more memory at compile time to inline a function specified with inline that is referred to by other functions before the inlined function's definition. With Deferred Inlining off, the compiler does not inline a function when it is referred to before its definition, even if the function is explicitly defined with inline.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000