coassoftwaresystems / delphi-modbus

Delphi ModbusTCP components
MIT License
119 stars 64 forks source link

Compiler error E2370 with TIdModBusServer.hpp #17

Closed Daijobou closed 1 month ago

Daijobou commented 7 years ago

This is possible a RAD Studio 2009 (C++Builder) compiler bug, in Rad Studio Berlin its working fine. I add this ticket only for Google. Compile a project with TIdModBusServer, I get two errors:

[BCC32 Error] IdModBusServer.hpp(120): E2370 [BCC32 Error] IdModBusServer.hpp(121): E2370

Line 120: property TModBusCoilWriteEvent OnWriteCoils = {read=FOnWriteCoils, write=FOnWriteCoils}; Line 121: property TModBusRegisterWriteEvent OnWriteRegisters = {read=FOnWriteRegisters, write=FOnWriteRegisters};

A maybe workaround is, to move this two lines in header-file in the next public: section. After this I can compile the project without a error. I can't tell the reason, but here is maybe a problem with convertion fixed-size arrays?

BugsDigger commented 7 years ago

Simply comment out "const" in generated declarations:

typedef void fastcall (closure TModBusCoilWriteEvent) (const Idcontext::TIdContext Sender, const int RegNr, const int Count, Byte /const/ * Data, // here const Modbustypes::TModBusRequestBuffer &RequestBuffer, Byte &ErrorCode);

and

typedef void fastcall (closure TModBusRegisterWriteEvent) (const Idcontext::TIdContext Sender, const int RegNr, const int Count, Word /const/ * Data, // here const Modbustypes::TModBusRequestBuffer &RequestBuffer, Byte &ErrorCode);