diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h
index d60d3fe0828..6e5a78b9a61 100644
--- a/cores/esp32/Arduino.h
+++ b/cores/esp32/Arduino.h
@@ -176,8 +176,8 @@ extern "C" void configTzTime(const char* tz,
 long random(long);
 #endif /* __cplusplus */
 
-#ifndef _GLIBCXX_VECTOR
-// arduino is not compatible with std::vector
+#if !defined(_GLIBCXX_VECTOR) && !defined(_GLIBCXX_FUNCTIONAL)
+// arduino is not compatible with std::vector or std::function
 #define min(a,b) ((a)<(b)?(a):(b))
 #define max(a,b) ((a)>(b)?(a):(b))
 #endif