Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling for 3.x.x ESP8266 board when use both WifiManager lib and MySensor lib. #1509

Closed
dungdao191299 opened this issue Sep 21, 2021 · 2 comments

Comments

@dungdao191299
Copy link

My code arduino for GatewayESP8266MQTTClient get error when compiling for 3.x.x ESP8266 Board. In my code, i used ESP8266WebServer lib for WifiManager Lib.
image

This is my error:
In file included from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/StreamDev.h:25, from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h:31, from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:340, from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:62: C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/StreamString.h:54:50: error: macro "max" requires 2 arguments, but only 1 given 54 | return std::numeric_limits<int16_t>::max(); | ^ In file included from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:60: C:\Users\ADMIN\Documents\Arduino\libraries\MySensors/MySensors.h:98: note: macro "max" defined here 98 | #define max(a,b) ((a)>(b)?(a):(b)) //!< max | In file included from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h:31, from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:340, from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:62: C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/StreamDev.h:51:50: error: macro "max" requires 2 arguments, but only 1 given 51 | return std::numeric_limits<int16_t>::max(); | ^ In file included from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:60: C:\Users\ADMIN\Documents\Arduino\libraries\MySensors/MySensors.h:98: note: macro "max" defined here 98 | #define max(a,b) ((a)>(b)?(a):(b)) //!< max | In file included from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h:31, from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:340, from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:62: C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/StreamDev.h:118:50: error: macro "max" requires 2 arguments, but only 1 given 118 | return std::numeric_limits<int16_t>::max(); | ^ In file included from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:60: C:\Users\ADMIN\Documents\Arduino\libraries\MySensors/MySensors.h:98: note: macro "max" defined here 98 | #define max(a,b) ((a)>(b)?(a):(b)) //!< max | In file included from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h:31, from C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:340, from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:62: C:\Users\ADMIN\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/StreamDev.h:145:50: error: macro "max" requires 2 arguments, but only 1 given 145 | return std::numeric_limits<int16_t>::max(); | ^ In file included from C:\Users\ADMIN\Desktop\20210921_gateway_new_topic\20210921_gateway_new_topic.ino:60: C:\Users\ADMIN\Documents\Arduino\libraries\MySensors/MySensors.h:98: note: macro "max" defined here 98 | #define max(a,b) ((a)>(b)?(a):(b)) //!< max |
image
Can Anyone help me?

@dungdao191299 dungdao191299 changed the title Error compiling for 3.x.x ESP8266 board when use both Wifi Manager and MySensor. Error compiling for 3.x.x ESP8266 board when use both WifiManager lib and MySensor lib. Sep 21, 2021
@dungdao191299
Copy link
Author

dungdao191299 commented Sep 21, 2021

I found a way to hack it. I move #include <MySensors.h> to the end of them. Like as:
image
My code was compiled and working. But do anyone know the reason? Sorry for my ignorance, i am a newbie

@virtual-maker
Copy link
Contributor

@dungdao191299
This is because MySensors lib defines a macro named max(), see: mysensors lib code

This max-macro brakes in multiple ESP8266 libraries code lines where max() is used in an different context, e.g. as a method of a class, or in your case the full qualified library function std::numeric_limits<int16_t>::max(), see: esp lib code

Basically this is a bad design decision and should be changed in MySensors library.
The ESP library uses a macro for max which is called max with a leading underscore: _max()
This macro should be used in the MySensors code to stay compatible with the multiple ESP8266 libraries.

It would be perfect helpful if you could create an additional issue for this.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants