I had compilation problems with the std::max() function. The change from unsigned long to a const uint32_t fixed this problem for me, because all the other variables in the std::max() function are const uint32_t as well.
I tried to compile for a ESP8266, ESP32 and just normal Arduino through the Arduino IDE 2 running on a MacBook. Got the same Error message for all 3 Boards.
I had compilation problems with the std::max() function. The change from unsigned long to a const uint32_t fixed this problem for me, because all the other variables in the std::max() function are const uint32_t as well.