Difference between revisions of "Inline"

From Lazarus wiki
(English translation of German page)
 
 
Line 11: Line 11:
 
The use of inline functions and inline procedures is switched off as standard. The compiler switch '''-Si''' or '''{$inline on}''' enables the use of inline functions and procedures.
 
The use of inline functions and inline procedures is switched off as standard. The compiler switch '''-Si''' or '''{$inline on}''' enables the use of inline functions and procedures.
  
{{Warning|Use inline with caution as there are currently bugs in all FPC versions. This affects all platforms.  
+
{{Warning| inline is a compiler hint and the compiler can ignore it. If the compiler warns you it has not inlined a certain code part marked as inline, you should remove the inline directive. This is not a bug. It is about code complexity}}
As of 14 February 2020}}
 
  
  

Latest revision as of 09:27, 25 January 2021

Deutsch (de) English (en)


Return to Reserved words.


The reserved word inline allows the compiler to copy a function or procedure in place of its call.

If the inline function or procedure is used frequently, this increases the speed of the program since the program does not have to branch to the subroutine.

The use of inline functions and inline procedures is switched off as standard. The compiler switch -Si or {$inline on} enables the use of inline functions and procedures.

Warning-icon.png

Warning: inline is a compiler hint and the compiler can ignore it. If the compiler warns you it has not inlined a certain code part marked as inline, you should remove the inline directive. This is not a bug. It is about code complexity


Example:

procedure subDemo(); inline;
  begin
  ...
  end;