Hi,

I don't understand why compilation of the program below failed in fpc
and objfpc mode. In tp and delphi mode it works as expected but in fpc
and objfpc mode the compiler complains :

  blob.pas(17,3) Error: Constants of objects containing a VMT aren't allowed
  blob.pas(17,3) Fatal: Syntax error, ";" expected but "(" found

Since my object has no virtual methods why a VMT ?

Thanks.


{$mode fpc}
program Blob;

type
  TBlob = object
    private
      fId : LongInt;

    public
      constructor Init;
      function Id: LongInt;
  end;

  PBlob=^TBlob;

const
  NullBlob : TBlob = (fId: 0);

{=== TBlob ===}
constructor TBlob.Init;
begin
  fId:=Random(1024) + 1;
end;

function TBlob.Id;
begin
  Id:=fId;
end;

var
  B : TBlob;
begin
  B:=NullBlob;
  WriteLn('B : ', B.Id);

  B.Init;
  WriteLn('B : ', B.Id);
end.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to