Forum > Windows (32/64)

Why Error: Incompatible type for arg no ?

(1/1)

svd71:
Hallo all,

I had tried to adopt the delphi code to Lazarus and got follow missunderstood.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit u_amqp_threads; {$mode objfpc}{$H+} interface uses  Classes, SysUtils,  AMQP.Connection, AMQP.Interfaces, AMQP.Classes  ; type  TProducerThread = Class(TThread)  Strict Private    FAMQP: TAMQPConnection;    FMaxWork: Integer;    FSleepMS: Integer;    Procedure WriteLine( Text: String );  Protected    Procedure Execute; Override;    constructor CreateP( AAMQP: TAMQPConnection; AMaxWork, ASleepMS: Integer );  End;   T_ConsumerThread = Class(TThread)  Strict Private    FAMQP: TAMQPConnection;    FChannel: IAMQPChannel;    FList: TStringList;    Procedure WriteLine( Text: String );  Protected    Procedure TerminatedSet; Override;    Procedure Execute; Override;    constructor Create( AAMQP: TAMQPConnection; const aList: TStringList );  End;    .... 


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---[code=pascal]unit u_custapp; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, custapp,  AMQP.Connection, AMQP.Interfaces, AMQP.Classes  , u_amqp_threads  ; type   { TAMQPApplication }   TAMQPApplication = class(TCustomApplication)  protected    procedure DoRun; override;  public    constructor Create(TheOwner: TComponent); override;    destructor Destroy; override;    class var AMQPApplication : TAMQPApplication;    class procedure AppStart;  public    mc1, mc2 : TStringList;    AMQP: TAMQPConnection;    Producer: TProducerThread;    Consumer1: T_ConsumerThread;    Consumer2: T_ConsumerThread;  end; implementation procedure TAMQPApplication.DoRun;var  ErrorMsg: String;begin    mc1 := TStringList.create;    mc2 := TStringList.create;    Consumer1 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc1 );    Consumer2 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc2 );    Producer := u_amqp_threads.TProducerThread.Create( AMQP, 2, 10 );                                                                     ..... [/code]

    Consumer1 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc1 );
u_custapp.pas(41,68) Error: Incompatible type for arg no. 2: Got "TStringList", expected "QWord"
classes.inc(225,21) Hint: Found declaration: constructor Create(Boolean;const QWord=`4194304`);

    Consumer2 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc2 );
u_custapp.pas(42,68) Error: Incompatible type for arg no. 2: Got "TStringList", expected "QWord"
classes.inc(225,21) Hint: Found declaration: constructor Create(Boolean;const QWord=`4194304`);

    Producer := u_amqp_threads.TProducerThread.Create( AMQP, 2, 10 );
u_custapp.pas(43,69) Error: Wrong number of parameters specified for call to "Create"
Z:\fpcdelux\fpcsrc\rtl\objpas\classes\classes.inc

It looks, that a compiler try to build the constructor from parent-class(TThread). Tjhe options like 'reintroduce' and 'overload' did not help. What is wrong in the code and how I can fix it?

tetrastes:
As I understand it, constructors must be public:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit u_amqp_threads; {$mode objfpc}{$H+} interface uses  Classes, SysUtils,  AMQP.Connection, AMQP.Interfaces, AMQP.Classes  ; type  TProducerThread = Class(TThread)  Strict Private    FAMQP: TAMQPConnection;    FMaxWork: Integer;    FSleepMS: Integer;    Procedure WriteLine( Text: String );  Protected    Procedure Execute; Override;  public    constructor CreateP( AAMQP: TAMQPConnection; AMaxWork, ASleepMS: Integer );  End;   T_ConsumerThread = Class(TThread)  Strict Private    FAMQP: TAMQPConnection;    FChannel: IAMQPChannel;    FList: TStringList;    Procedure WriteLine( Text: String );  Protected    Procedure TerminatedSet; Override;    Procedure Execute; Override;  public     constructor Create( AAMQP: TAMQPConnection; const aList: TStringList );  End;    .... 
And there is typo (CreateP vs Create):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TProducerThread = Class(TThread).....    constructor CreateP( AAMQP: TAMQPConnection; AMaxWork, ASleepMS: Integer ); ...... Producer := u_amqp_threads.TProducerThread.Create( AMQP, 2, 10 ); 

svd71:
Thank you!

tetrastes:
Just in case: I have checked it in Lazarus and have got explicit "Warning: constructor should be public".

Navigation

[0] Message Index

Go to full version