When you compile using -S2 parameter you are compiling in objfpc mode. This mode is not exactly compatible with Delphi. In this particular case, the problem is that in objfpc mode method parameters can't have the same name as the object properties and fields (that's what "Duplicate identifier ..." errors mean). That's often very nice safety-check, however it makes many Delphi code invalid in objfpc mode.

Solution is to compile in delphi mode:
  fpc -Mdelphi mat.pas
works OK.

Alan Mead wrote:
I am trying to compile a Delphi matrix package using fpc 1.9.4 and I
don't know if I misunderstand FPC's overloading or if there is an FPC
problem. The code is located here:

http://www.fssc.demon.co.uk/Delphi/delphi.htm#TMatrix

Lines 84-85 define a transpose method:

84     function  transpose : TMatrix; {overload;}
85     function  transpose (m : TMatrix) : TMatrix; {overload;}

(I commented out the overload keyword.. doesn't seem to matter.).  I
don't see any forward declaration of 'transpose':

[EMAIL PROTECTED] misc code]$ grep -i transpose mat.pas
function transpose : TMatrix; overload;
function transpose (m : TMatrix) : TMatrix;
overload;
{ Transpose matrix 'Self', Self is thus destroyed and replaced }
{ Usage: A.transpose }
function TMatrix.Transpose : TMatrix;
{ move data from transpose to Self }
{ Transpose the matrix 'm' into Self }
{ Usage: T.transpose (A); Tranposes A and puts result into T }
{ Will also accept T.transpose (T) }
function TMatrix.Transpose (m : TMatrix) : TMatrix;
raise EMatrixSizeError.Create ('Destination matrix has incorrect
dimensions for transpose');
{ If the user is trying to transpose itself.... }
tmp.Transpose (st);
Self.Transpose (ns);


This is the output when I try to compile:

[EMAIL PROTECTED] misc code]$ fpc -gl -S2 -Cr -Co mat.pas
Free Pascal Compiler version 1.9.4 [2004/05/30] for i386
Copyright (c) 1993-2004 by Florian Klaempfl
Target OS: Linux for i386
Compiling mat.pas
mat.pas(85,41) Error: Duplicate identifier "M"
mat.pas(85,30) Error: Function is already declared Public/Forward
"TMatrix.transpose:TMatrix"
mat.pas(87,38) Error: Duplicate identifier "M"
mat.pas(89,38) Error: Duplicate identifier "M"
mat.pas(90,38) Error: Duplicate identifier "M"
mat.pas(91,30) Error: Function is already declared Public/Forward
"TMatrix.mult(Extended):TMatrix"
mat.pas(93,38) Error: Duplicate identifier "M"
mat.pas(103,40) Error: Duplicate identifier "M"
mat.pas(117,73) Error: Duplicate identifier "c"
mat.pas(118,48) Error: Duplicate identifier "r"
mat.pas(118,73) Error: Duplicate identifier "c"
mat.pas(119,59) Error: Duplicate identifier "r"
mat.pas(127,1) Fatal: There were 12 errors compiling module, stopping

Any ideas on getting fpc to compile this? I'm confused by the
reference to 'm'?


-Alan

_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to