14.9.5 inline

Procedures that are declared inline are copied to the places where they are called. This has the effect that there is no actual procedure call, the code of the procedure is just copied to where the procedure is needed, this results in faster execution speed if the function or procedure is used a lot. It is obvious that inlining large functions does not make sense.

By default, inline procedures are not allowed. Inline code must be enabled using the command-line switch -Si or {$inline on} directive.

Remark

  1. inline is only a hint for the compiler. This does not automatically mean that all calls are inlined; sometimes the compiler may decide that a function simply cannot be inlined, or that a particular call to the function cannot be inlined. If so, the compiler will emit a warning.
  2. In old versions of Free Pascal, inline code was not exported from a unit. This meant that when calling an inline procedure from another unit, a normal procedure call will be performed. Only inside units, Inline procedures are really inlined. As of version 2.0.2, inline works across units.
  3. Recursive inline functions are not allowed. i. e. an inline function that calls itself is not allowed.