使用TThread构造函数时出现Pascal 2.6.2错误

时间:2013-05-07 10:00:33

标签: delphi fpc tthread

Free Pascal 2.6.2编译器(使用Delphi模式)抱怨

program project16416258;

{$mode Delphi}

uses
  Classes;

type
  TFPCTestThread = class(TThread)
  public
    constructor Create(CreateSuspended: Boolean);
  end;

constructor TFPCTestThread.Create(CreateSuspended: Boolean);
begin
  inherited;
end;

begin
end.

出现此错误消息:

ThroughputTestUnit.pas(82,19) Error: Wrong number of parameters
specified for call to "Create" Hint: Found declaration: constructor
TThread.Create(Boolean,const LongWord="4194304");

我用

修复了它
  inherited Create (CreateSuspended);  

它似乎是由2.6.2的变化引起的,TThread现在有一个带有可选第二个参数的构造函数声明:

 constructor Create(CreateSuspended: Boolean;
                    const StackSize: SizeUInt = DefaultStackSize);   

1 个答案:

答案 0 :(得分:3)

inherited;调用基类构造函数Create(CreateSuspended: Boolean)。由于基类没有带有一个布尔参数的构造函数,所以你得到了错误。