arduino-libraries / Bridge

Bridge Library for Arduino
http://arduino.cc/
13 stars 28 forks source link

Compilation errors when Including Bridge.h or Invoking Bridge.begin(): no known conversion for argument 1 from ‘const __FlashStringHelper*’ to ‘const char*’ #18

Closed nigelnquande closed 5 years ago

nigelnquande commented 7 years ago

I tried to run the "Process" example from the Bridge Library. After receiving the SerialUSB not found in this scope error and changing SerialUSB to Serial, I received the following error message:

In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from /usr/share/arduino/libraries/Bridge/Bridge.h:26,
                 from /usr/share/arduino/libraries/Bridge/BridgeServer.h:22,
                 from /usr/share/arduino/libraries/Bridge/BridgeServer.cpp:19:
/usr/share/arduino/libraries/Bridge/BridgeServer.cpp: In member function ‘virtual void BridgeServer::begin()’:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:38:95: error: conversion from ‘const __FlashStringHelper*’ to non-scalar type ‘String’ requested
 #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
                                                                                               ^
/usr/share/arduino/libraries/Bridge/BridgeServer.cpp:33:20: note: in expansion of macro ‘F’
   String address = F("127.0.0.1");
                    ^
/usr/share/arduino/libraries/Bridge/BridgeServer.cpp:35:13: error: no match for ‘operator=’ (operand types are ‘String’ and ‘const __FlashStringHelper*’)
     address = F("0.0.0.0");
             ^
/usr/share/arduino/libraries/Bridge/BridgeServer.cpp:35:13: note: candidates are:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from /usr/share/arduino/libraries/Bridge/Bridge.h:26,
                 from /usr/share/arduino/libraries/Bridge/BridgeServer.h:22,
                 from /usr/share/arduino/libraries/Bridge/BridgeServer.cpp:19:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:83:11: note: String& String::operator=(const String&)
  String & operator = (const String &rhs);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:83:11: note:   no known conversion for argument 1 from ‘const __FlashStringHelper*’ to ‘const String&’
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:84:11: note: String& String::operator=(const char*)
  String & operator = (const char *cstr);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:84:11: note:   no known conversion for argument 1 from ‘const __FlashStringHelper*’ to ‘const char*’

I don't understand any of this, but I think the F macro is broken.

This happens any time I use the Bridge library, regardless of baud rate specified in Bridge.begin().

In case it's relevant, I'm using an Iduino Yun Shield on a Leonardo R3 and IDE v 2.1.0.5

per1234 commented 5 years ago

These errors will only occur when using extremely outdated versions of the Arduino IDE like your 2:1.0.5 installation. Those IDE versions are no longer supported and, due to now having the 1.5 library format, the Bridge library is no longer compatible with them either.

When you install the Arduino IDE via apt install arduino you get this very outdated IDE version. Please always install the Arduino IDE from the official downloads page: https://www.arduino.cc/en/Main/Software