hsaturn / TinyMqtt

ESP 8266 / 32 / WROOM Small footprint Mqtt Broker and Client
GNU General Public License v3.0
197 stars 41 forks source link

simple-broker not compiling #103

Open olleyOop opened 2 months ago

olleyOop commented 2 months ago

Hello,

after I updated the library in Arduino IDE 2.3.2 I can't compile my project anymore. Even if I try to compile the example "simple-broker" I get the following error:

In file included from c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyConsole.h:5, from c:\Users\oreic\Documents\Arduino\libraries\TinyMqtt\src/StringIndexer.h:6, from c:\Users\oreic\Documents\Arduino\libraries\TinyMqtt\src/TinyMqtt.h:39, from C:\Users\oreic\AppData\Local\Temp.arduinoIDE-unsaved2024722-3888-hvfh85.6dmcg\simple-broker\simple-broker.ino:1: c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h: In member function 'TinyTerm::CallBackKey TinyTerm::onKey(CallBackKey)': c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h:95:56: error: call of overloaded 'exchange(TinyTerm::CallBackKey&, TinyTerm::CallBackKey&)' is ambiguous 95 | CallBackKey onKey(CallBackKey cb) { return exchange(callback_key, cb); } | ~~^~~~ c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h:12:3: note: candidate: 'T exchange(T&, U&&) [with T = std::function<void(TinyTerm::KeyCode)>; U = std::function<void(TinyTerm::KeyCode)>&]' 12 | T exchange(T& obj, U&& new_value) | ^~~~ In file included from c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h:6: c:\users\oreic\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\include\c++\12.2.0\utility:93:5: note: candidate: 'constexpr _Tp std::exchange(_Tp&, _Up&&) [with _Tp = function<void(TinyTerm::KeyCode)>; _Up = function<void(TinyTerm::KeyCode)>&]' 93 | exchange(_Tp& obj, _Up&& __new_val) | ^~~~ c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h: In member function 'TinyTerm::CallBackMouse TinyTerm::onMouse(CallBackMouse)': c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h:96:80: error: call of overloaded 'exchange(TinyTerm::CallBackMouse&, TinyTerm::CallBackMouse&)' is ambiguous 96 | CallBackMouse onMouse(CallBackMouse cb) { mouseTrack(true); return exchange(callback_mouse, cb); } | ~~^~~~~~ c:\Users\oreic\Documents\Arduino\libraries\TinyConsole\src/TinyTerm.h:12:3: note: candidate: 'T exchange(T&, U&&) [with T = std::function<void(const TinyTerm::MouseEvent&)>; U = std::function<void(const TinyTerm::MouseEvent&)>&]' 12 | T exchange(T& obj, U&& new_value) | ^~~~ c:\users\oreic\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\include\c++\12.2.0\utility:93:5: note: candidate: 'constexpr _Tp std::exchange(_Tp&, _Up&&) [with _Tp = function<void(const TinyTerm::MouseEvent&)>; _Up = function<void(const TinyTerm::MouseEvent&)>&]' 93 | exchange(_Tp& obj, _Up&& __new_val) | ^~~~ C:\Users\oreic\AppData\Local\Temp.arduinoIDE-unsaved2024722-3888-hvfh85.6dmcg\simple-broker\simple-broker.ino: In function 'void setup()': C:\Users\oreic\AppData\Local\Temp.arduinoIDE-unsaved2024722-3888-hvfh85.6dmcg\simple-broker\simple-broker.ino:29:41: error: 'red' is not a member of 'TinyConsole' 29 | Console << TinyConsole::red << "** PLEASE MODIFY ssid/password *****" << endl; | ^~~ C:\Users\oreic\AppData\Local\Temp.arduinoIDE-unsaved2024722-3888-hvfh85.6dmcg\simple-broker\simple-broker.ino:38:27: error: 'green' is not a member of 'TinyConsole' 38 | Console << TinyConsole::green << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl; | ^~~~~

exit status 1

Compilation error: 'red' is not a member of 'TinyConsole'

TinyMqtt 0.9.16 TinyConsole 0.4.6

Any help would be appreciated.

papercodeIN commented 2 months ago

Same error for me as well any solution for this problem ?

Tschmidt9490 commented 2 months ago

go in to the tinyconsole library and switch this

TinyString& TinyString::operator=(TinyString && other) { if (this == &other) return this; clear(); str = std::exchange(other.str, str); size = std::exchange(other.size, size); free = std::exchange(other.free, free); return this; }

With this

TinyString& TinyString::operator=(TinyString && other) { if (this == &other) return this; clear(); std::swap(other.str, str); std::swap(other.size, size); std::swap(other.free, free); return this; }

papercodeIN commented 2 months ago

go in to the tinyconsole library and switch this

TinyString& TinyString::operator=(TinyString && other) { if (this == &other) return this; clear(); str = std::exchange(other.str, str); size = std::exchange(other.size, size); free = std::exchange(other.free, free); return this; }

With this

TinyString& TinyString::operator=(TinyString && other) { if (this == &other) return this; clear(); std::swap(other.str, str); std::swap(other.size, size); std::swap(other.free, free); return this; }

Thank You friend, also can you help one more thing ? Could you please tell the file name ? Really sorry for silly question.

Tschmidt9490 commented 2 months ago

Tinystring.cpp

lutorm commented 2 weeks ago

I'm getting the same error, but my Tinystring.cpp already uses std::swap. Besides, the error above says that the call in TinyTerm::onKey is ambiguous. If I change "exchange" to "::exchange" to force the use of the template at the top of the file, the ambiguity is broken. But then I'm getting another error:

/tmp/.arduinoIDE-unsaved2024930-2070929-yr320l.vzzcp/simple-broker/simple-broker.ino: In function 'void setup()':
/tmp/.arduinoIDE-unsaved2024930-2070929-yr320l.vzzcp/simple-broker/simple-broker.ino:29:41: error: 'red' is not a member of 'TinyConsole'
   29 |                 Console << TinyConsole::red << "****** PLEASE MODIFY ssid/password *************" << endl;
      |                                         ^~~
/tmp/.arduinoIDE-unsaved2024930-2070929-yr320l.vzzcp/simple-broker/simple-broker.ino:38:27: error: 'green' is not a member of 'TinyConsole'
   38 |   Console << TinyConsole::green << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;

and indeed TinyConsole does not have any such members...

There are also numerous other errors, I think this is not kept up to date.