Issue with ESP32 compilation (stl_algobase.h)

Hello guys just wondering what is the reason of the issue, I am on a mac

/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:243:56: error: macro"min" passed 3 arguments, but takes just 2

min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Seems like a macro and a function definition are colliding. Which min do you want to use? std::min? Then write std::min and maybe #undef min or #undef MIN at the top.

Yup, totally right, I had to modify the xtensa file for the project, looks like it fixed it :slight_smile:

1 Like

Great to know it worked!

Actually it should be sufficient to just #undef min after the header that does the #define min(..) in your main CPP / INO file. And using namespace std; should be avoided in this case if you have it, because min can then become ambigious.

I had no code with min or max declared, my guess is that, it was messing with internal/system headers