Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#30 Bad header built in C++Builder 2010

open
nobody
None
5
2010-09-15
2010-09-15
PKy
No

There is a conflict in ECOMPort constructors when C++ header is built. Below you see the part of the header for it.

CPort.hpp:
ECOMPort (int) & CreateRes (int) create constructor which have same parameters and this won't compile. So you have to add a bogus parameter to the either one (= latter). I don't know if this really breaks anything, but I think this issue could be worked-around by adding a "DUMB" parameter or making the CreateRes parameter on Delphi side to something else, like int64 or double :). CreateRes is inherited from the Sysutils::Exception so i don't know if it could be reintroduced with other parameterset or something like that. But adding the double to the header works.

class DELPHICLASS EComPort;
class PASCALIMPLEMENTATION EComPort : public Sysutils::Exception
{
typedef Sysutils::Exception inherited;

private:
int FWinCode;
int FCode;

public:
__fastcall EComPort(int ACode, int AWinCode, System::UnicodeString port);
<b>__fastcall EComPort(int ACode);</b>
__property int WinCode = {read=FWinCode, write=FWinCode, nodefault};
__property int Code = {read=FCode, write=FCode, nodefault};
public:
/* Exception.CreateFmt */ inline __fastcall EComPort(const System::UnicodeString Msg, System::TVarRec const *Args, const int Args_Size) : Sysutils::Exception(Msg, Args, Args_Size) { }
<b>/* Exception.CreateRes */ inline __fastcall EComPort(int Ident<u>, double ADUMB)/* overload</u> */ : Sysutils::Exception(Ident) { }</b>
/* Exception.CreateResFmt */ inline __fastcall EComPort(int Ident, System::TVarRec const *Args, const int Args_Size)/* overload */ : Sysutils::Exception(Ident, Args, Args_Size) { }
/* Exception.CreateHelp */ inline __fastcall EComPort(const System::UnicodeString Msg, int AHelpContext) : Sysutils::Exception(Msg, AHelpContext) { }
/* Exception.CreateFmtHelp */ inline __fastcall EComPort(const System::UnicodeString Msg, System::TVarRec const *Args, const int Args_Size, int AHelpContext) : Sysutils::Exception(Msg, Args, Args_Size, AHelpContext) { }
/* Exception.CreateResHelp */ inline __fastcall EComPort(int Ident, int AHelpContext)/* overload */ : Sysutils::Exception(Ident, AHelpContext) { }
/* Exception.CreateResFmtHelp */ inline __fastcall EComPort(System::PResStringRec ResStringRec, System::TVarRec const *Args, const int Args_Size, int AHelpContext)/* overload */ : Sysutils::Exception(ResStringRec, Args, Args_Size, AHelpContext) { }
/* Exception.Destroy */ inline __fastcall virtual ~EComPort(void) { }

};

Other problem seems to be with the SetPort which turns to SetPortA for some reason... More on this later.

Discussion

  • PKy
    PKy
    2010-09-30

    WORKAROUND:

    Update EComPort interface following:

    // exception class for ComPort Library errors
    EComPort = class(Exception)
    private
    FWinCode: Integer;
    FCode: Integer;
    public
    constructor Create(ACode: Integer; AWinCode: Integer; port:String);
    constructor CreateNoWinCode(ACode: Integer);

    // PKy 30.9.2010. REINTRODUCED WITH DUMMY BOOL TO ALLOW CORRECT C++ HEADER
    constructor CreateRes(Ident: Integer; Dummy: Boolean); reintroduce; {overload;}

    property WinCode: Integer read FWinCode write FWinCode;
    property Code: Integer read FCode write FCode;
    end;

    Then add to implementation following:

    // PKy 30.9.2010. REINTRODUCED WITH DUMMY BOOL TO ALLOW CORRECT C++ HEADER
    constructor EComPort.CreateRes(Ident: Integer; Dummy: Boolean);
    begin

    end;

    Now you won't get anymore this error on each rebuild