ArduinoModbus icon indicating copy to clipboard operation
ArduinoModbus copied to clipboard

printf compile error

Open chrisflesher opened this issue 5 years ago • 2 comments

I tried compiling the WiFiModbusServer example and am getting:

/home/chris/Arduino/libraries/ArduinoModbus/src/libmodbus/modbus-tcp.cpp:32:21: error: expected unqualified-id before '{' token
   32 | #define printf(...) {}
      |                     ^
/home/chris/.arduino15/packages/adafruit/hardware/samd/1.6.4/cores/arduino/Print.h:88:10: note: in expansion of macro 'printf'
   88 |     void printf(const char[], ...);
      |          ^~~~~~

chrisflesher avatar Nov 13 '20 13:11 chrisflesher

I tried adding a #define DEBUG before #include <ArduinoModbus.h and it didn't fix it but commenting out this block in modbus-tcp.cpp got rid of the compile error:

// #ifndef DEBUG
// #define printf(...) {}
// #define fprintf(...) {}
// #endif

chrisflesher avatar Nov 13 '20 14:11 chrisflesher

Yes, compiling the RTU examples for Adafruit M0 and M4 produces exactly the same error, but not so for an Arduino AVR micro. Commenting out (just) the #define printf(...) { } in modbus-tcp.cpp (line 32) avoids the compile error.

Just to add: this is Arduino IDE 1.8.13 and 1.8.14 (build 2020/10/09 12:33) compiling the ArduinoModbus examples sketches.

tgthomas avatar Nov 16 '20 01:11 tgthomas