homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 307 forks source link

After including Homie.h min() function has to be called as std::min() #22

Closed furyfire closed 8 years ago

furyfire commented 8 years ago

After including Homie.h any code that uses the min() function will fail to compile unless you give it a namespace. This is unlike other Arduino libs and causes confusion.

include

include

void setup() { std::min(2,3); }

void loop() { }

marvinroger commented 8 years ago

It's not Homie' fault.

The min() you're using when you call the min() function is not the std one, but the one defined by a #define there. The problem is ESP8266WiFi.h undefines both min and max. You can try:

#include <ESP8266WiFi.h>

void setup() {
  min(2,3);
}

void loop() {
  delay(100);
}

It won't work either. The issue is tracked at esp8266/Arduino#398

As a workaround, you can use _min and _max.