In my Application I have two thread objects (Outer and Sash) that inherit from a base thread object (FrameObject) of type TThread. This all works fine in D7. The application needs to be extended and I am taking this opportunity to move it to D2010 - however when I try to compile Delphi complains that the FrameObject Create method declaration differs from the previous declaration.
The Class types and Constructors are shown below;
TFrameObject = class(TThread)
constructor TFrameObject.Create(BuildType: TBuildType; OnBatchStep: TBatchNotify; OnThreadComplete: TNotifyTermination);
begin
inherited Create(True);
...
end;
TOuter = class (TFrameObject)
constructor Create(BuildType: TBuildType; OnBatchStep: TBatchNotify; OnThreadComplete: TNotifyTermination; ExceptionHandler: TExceptionHandler);
begin
inherited create(BuildType, OnBatchStep, OnThreadComplete);
fExceptionHandler := ExceptionHandler;
...
end;
TSash =开发者_如何学JAVA class (TFrameObject)
constructor Create(BuildType: TBuildType; OnBatchStep: TBatchNotify; OnThreadComplete: TNotifyTermination; ExceptionHandler: TExceptionHandler);
begin
inherited create(BuildType, OnBatchStep, OnThreadComplete);
fExceptionHandler := ExceptionHandler;
...
end;
The D2010 code is a direct copy of the D7 source files and as I say, this all works fine in D7 (perhaps it shouldn't!) - so where am I going wrong?
Check for types declared in multiple units where one of them is used in the interface and another in the implementation section, so for example TBuildType
in your TFrameObject
declaration (in the interface section) would resolve to UnitA.TBuildType
and implementation to UnitB.TBuildType
.
My guess at to what is happening here is that the uses
clause in your implementation section is declaring a TBuildType
, TBatchNotify
or TNotifyTermination
that is different from the one used in your interface section where you declare the constructor.
A quick way to check would be to fully qualify those types in the implementation of TFrameObject.Create
.
As per other answers, a newly introduction type in a unit used in the implementation section hiding a type of the same name used or declared in the interface section is the most likely explanation.
However, unlike previous answers, since the problem only occurs in D2010 and not D7 then I would suspect the ExceptionHandler parameter of type TExceptionHandler, since D2010 includes a type with this name declared in ToolsAPI\IStreams.
You could qualify the name in the implementation section:
TFrameObject.Create(... ExceptionHandler: MyUnit.TExpectionHandler)
Where "MyUnit" is the name of the unit containing the "real" TExceptionHandler that you wish to use.
Or, you could alias the type in the interface section and change your parameter lists to consistently use the aliased type in both interface and implementation of this unit:
interface
type
TFrameExceptionHandler = TExceptionHandler;
TFrameObject = class...
...
constructor Create(... ExceptionHandler: TFrameExceptionHandler);
end;
implementation
constructor TFrameObject.Create(... ExceptionHandler: TFrameExceptionHandler);
精彩评论