[fpc-pascal] inline and other modifiers

Bernd prof7bit at googlemail.com
Fri Dec 16 21:36:01 CET 2011


I have the following:

unit foo;

{$mode objfpc}{$H+}

interface
uses
  foobar;

function BitCnt(ABitmap: TBitBoard): Integer;

implementation

{$ifdef cpu386}
function BitCnt(ABitmap: TBitBoard): Integer; assembler; register; nostackframe;
asm
  ...
end;
{$else}
function BitCnt(ABitmap: TBitBoard): Integer; inline;
begin
  ...
end;

This seems to compile and work as intended, no matter which of the two
implementations I choose. But I wonder how this can work? I always
thought that what is written in the interface section is
authoritative. How can the compiler properly use this unit and call
the function when the implementation actually implements a completely
different calling convention (inline) than the one that is declared in
the interface section?

Bernd



More information about the fpc-pascal mailing list