Delphi Error – W1029 Duplicate %s ‘%s’ with identical parameters will be inacessible from C++

Delphi Compiler Error

W1029 Duplicate %s ‘%s’ with identical parameters will be inacessible from C++

Reason for the Error & Solution

An object file is being generated and Two, differently named, constructors or destructors with identical parameter lists have been created; they will be inaccessible if the code is translated to an HPP file because constructor and destructor names are converted to the class name. In C++ these duplicate declarations will appear to be the same function.

unit Produce;
interface
  type
    Base = class
      constructor ctor0(a, b, c : integer);
      constructor ctor1(a, b, c : integer);
    end;

implementation
constructor Base.ctor0(a, b, c : integer);
begin
end;

constructor Base.ctor1(a, b, c : integer);
begin
end;

begin
end.


As can be seen in this example, the two constructors have the same signature and thus, when the file is compiled with one of the -j options, will produce this warning.

unit Solve;
interface
  type
    Base = class
      constructor ctor0(a, b, c : integer);
      constructor ctor1(a, b, c : integer; dummy : integer = 0);
    end;

implementation
constructor Base.ctor0(a, b, c : integer);
begin
end;

constructor Base.ctor1(a, b, c : integer; dummy : integer);
begin
end;

begin
end.


A simple method to solve this problem is to change the signature of one of constructors, for example, to add an extra parameter. In the example above, a default parameter has been added to ctor1. This method of approaching this error has the benefit that Delphi code using ctor1 does not need to be changed. C++ code, on the other hand, will have to specify the extra parameter to allow the compiler to determine which constructor is desired.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...