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

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Aug 3 09:31:15 CEST 2010


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)
    FStream : TStream;
    PackageName: String;
    Module: TPasModule;
    ModuleName: String;
    FLastURL : DomString;
    // 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 ]------------------------------
  TIPFNewWriter = class(TLinearWriter)
    InPackageOverview: Boolean;
    InHeading: Boolean;
    FInHeadingText: string;
    OrderedList: boolean;
    procedure FlushBuffer;
    FLink: String;
    FTableCount : Integer;
    FInVerbatim : Boolean;
    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+}

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

More information about the fpc-pascal mailing list