[fpc-pascal] FPC 2.5.1 cannot override a virtual method in fpdoc?

Michael Van Canneyt michael at freepascal.org
Tue Aug 3 09:49:02 CEST 2010


Hello,

I can confirm this problem. We have experienced it in a project of ours,
and it disappears if the units containing the parent and child class are
compiled in 1 run; we only had it if first the parent class' unit was
compiled, and later the child's class unit.

It appeared with the same type of arguments: ansistring and array of const.

Michael.

On Tue, 3 Aug 2010, Graeme Geldenhuys wrote:

> Hi,
>
> I'm trying to apply my final changes to the new Linear IPF writer for
> fpdoc. I updated to the latest FPC 2.5.1 today. Did a make clean and build
> the whole FPC 2.5.1 for 64-bit Linux - no problems.
>
> I then switched to by fpdoc_ipf branch which is based on the latest FPC
> 2.5.1 code. Trying to compile fpdoc now with 2.5.1, I get the following
> error. This has me stumped. I just can't see what the problem is. Can
> anybody shed some light on why I can't override a virtual method?
>
> Error when trying to compile fpdoc.
> -----------------------------
> Hint: Start of reading config file /home/graemeg/.fpc.cfg
> Hint: End of reading config file /home/graemeg/.fpc.cfg
> Free Pascal Compiler version 2.5.1 [2010/08/03] for x86_64
> Copyright (c) 1993-2009 by Florian Klaempfl
> Target OS: Linux for x86-64
> Compiling fpdoc.pp
> Compiling dw_ipflin.pas
> dw_ipflin.pas(70,15) Error: There is no method in an ancestor class to be
> overridden: "TIPFNewWriter.WriteLnF(const AnsiString,const Array Of Const);"
> dw_ipflin.pas(161,1) Fatal: There were 1 errors compiling module, stopping
>
> -------------------------------------------
>
>
> Here is the related code.... The method I want to override in a descendant
> class is WriteLnF()
>
> -----------------------[ dwlinear.pp ]-----------------------------
> TLinearWriter = Class(TFPDocWriter)
>  published
>    FStream : TStream;
>    PackageName: String;
>    Module: TPasModule;
>    ModuleName: String;
>    FLastURL : DomString;
>  protected
>    // Writing support.
>    procedure Write(const s: String); virtual;
>    procedure WriteLn(const s: String); virtual;
>    procedure WriteF(const s: String; const Args: array of const); virtual;
>    procedure WriteLnF(const s: String; const Args: array of const);
> virtual;  //   <<---  ****   The method I want to override later ****
>    Function  PushWriteContext(S : TStream) : TStream;
> ...
> ------------------------------------------------------
>
>
> ... and here is my new IPF unit which descends from TLinearWriter.
>
> -----------------------[ dw_ipflin.pas ]------------------------------
> type
>  TIPFNewWriter = class(TLinearWriter)
>  private
>    InPackageOverview: Boolean;
>    InHeading: Boolean;
>    FInHeadingText: string;
>    OrderedList: boolean;
>    procedure FlushBuffer;
>  protected
>    FLink: String;
>    FTableCount : Integer;
>    FInVerbatim : Boolean;
>    Inlist,
>    TableRowStartFlag,
>    TableCaptionWritten: Boolean;
>    fWrap: boolean;
>    fColCount: integer;
>    Fline: string;  // line buffer for textwrap support
>    // extras
>    procedure Write(const s: String); override;
>    procedure WriteLn(const s: String); override;
>    procedure WriteLnF(const s: String; const Args: array of const);
> override;   // <<---- *****   Compiler error is here  ******
>    procedure WriteBeginDocument; override;
>
> ------------------------------------------------------
>
>
> Is there some new language rule in FPC 2.5.1 that doesn't allow you to
> override virtual methods for some reason?
>
>
> All units in question have the following defined at the top of each unit.
> So it's not a AnsiString vs ShortString issue.
>
>   {$mode objfpc}{$H+}
>
>
>
> Regards,
>  - Graeme -
>
> -- 
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://opensoft.homeip.net/fpgui/
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list