Skip to content

#define MODBUSRTU_REDE leads to compiler errors #323

@fredlcore

Description

@fredlcore

It's not an actual error, but current default settings in Arduino IDE lead to this error when compiling with MODBUSRTU_REDE enabled:

/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.cpp: In member function 'bool ModbusRTUTemplate::rawSend(uint8_t, uint8_t*, uint8_t)':
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.cpp:138:6: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
      if (_txPin >= 0)
      ^~
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.cpp:140:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if (_rxPin >= 0)
   ^~
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.cpp:167:6: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
      if (_txPin >= 0)
      ^~
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.cpp:169:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if (_rxPin >= 0)
   ^~
cc1plus: some warnings being treated as errors
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/Modbus.cpp: In member function 'void Modbus::slavePDU(uint8_t*)':
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/Modbus.cpp:318:25: warning: comparison is always false due to limited range of data type [-Wtype-limits]
             if (bufSize > MODBUS_MAX_FRAME) {  // Frame to return too large

Using library modbus-esp8266 at version 4.1.0 in folder: /Users/frederik/Documents/Arduino/libraries/modbus-esp8266 
exit status 1

Compilation error: exit status 1

It's really just a matter of indention. By moving the commands into the same line as the if-statement, the error disappears.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions