[fpc-pascal] How does inline work?

Roland Schaefer roland.schaefer at fu-berlin.de
Sun Nov 22 14:05:14 CET 2009


Jonas Maebe wrote:
> unit tt;
> 
> interface
> 
> {$Inline on}
> type
> TForm1 = class
>   private
>     procedure DebugInfo; inline;
>   public
>     procedure DoSomething;
> end;
> 
> Implementation
> 
> procedure TForm1.DebugInfo;
> begin
> {$ifdef debug}
>    DebugInfo
> {$endif}
> end;
> 
> procedure TForm1.DoSomething;
> begin
> DebugInfo;
> end;
> 
> end.

While on the subject of inline: I always wondered (currently using fpc
2.2.4 on W32 and GNU/Linux) why one can have inline hints either just in
the interface (as in the ex. above), or the implementation, or both.
This seems to be the case both for class methods and single
functions/procedures. I haven't checked under which conditions the
compiler actually inlines the code, though. Is that an intended
behavior? If so, why?

Regards
Roland



More information about the fpc-pascal mailing list