dersimn / ArduinoPubSubClientTools

11 stars 3 forks source link

Compilation error: 'function' in namespace 'std' does not name a template type #3

Open duccio opened 5 years ago

duccio commented 5 years ago

Hello,

I'm trying to use the library but I got:

In file included from /Users/xxx/Desktop/testar/src/main.cpp:1:0: /Users/xxx/Documents/Arduino/libraries/PubSubClientTools/PubSubClientTools.h:41:14: error: 'function' in namespace 'std' does not name a template type std::function<void(PUBSUBCLIENT_CALLBACK_PARAMETERS)> mqtt_callback = std::bind(&PubSubClientTools::callback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);

the compilation command:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -f data-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I/Application s/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs -I/Users/xxx/Docume nts/Arduino/libraries/PubSubClientTools -I/Users/xxx/Documents/Arduino/libraries/PubSubClient/src /Users/xxx/Desktop/testar/build/sketch/main.cpp.cpp -o /Users/xxx/Deskto p/testar/build/sketch/main.cpp.cpp.o

Can you help, please?

Thanks.

dersimn commented 5 years ago

The library works only on ESP8266 for now. Depending on how often you send messages a regular AVR based Arduino might be too slow anyways.

The problem why it doesn't compile now is because of this line. Here is how it should look like (not copy&paste, but just to get an impression). I don't have an Arduino Ethernet or similar to test though, since I'm only using ESP8266 when I need a network attached micro-controller.

duccio commented 5 years ago

Yeah, thanks for the reply @dersimn. I was looking for ArduinoPubSubClientTools thanks to another OS project, ArduinoUnifiedLog. I'm interested in Serial Logging (and MQTT in the future, but without the ESP8266) and I was unable to compile on Arduino because the Arduino toolkit try to compile all files in ArduinoUnifiedLog (also the MQTT one, that depends on ArduinoPubSubClientTools). I opened an issue on ArduinoUnifiedLog (https://github.com/dersimn/ArduinoUnifiedLog/issues/1) and I'm trying to discover how to avoid all files compilation on Arduino 😉