[fpc-pascal]Where is the error?

Alan Mead cubrewer at yahoo.com
Tue Aug 31 21:37:32 CEST 2004


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':

[amead at alan 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:

[amead at alan 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




More information about the fpc-pascal mailing list