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

PIO build fails when esp8266/nodemcu2 board is used #646

Closed
supunj opened this issue May 2, 2016 · 4 comments
Closed

PIO build fails when esp8266/nodemcu2 board is used #646

supunj opened this issue May 2, 2016 · 4 comments

Comments

@supunj
Copy link

supunj commented May 2, 2016

Hi,

I've recently migrated my legacy IoT(https://github.com/supunj/libesp8266) project to PIO(https://github.com/supunj/libesp8266pio). All went well except for one which I believe
may be related to PIO pulling a different version of esp8266 SDK.

Below is the error I get

In file included from .pioenvs/nodemcuv2/ESP8266WiFi/WiFiClient.h:25:0,
from .pioenvs/nodemcuv2/ESP8266WiFi/ESP8266WiFi.h:39,
from .pioenvs/nodemcuv2/ESP8266mDNS/ESP8266mDNS.h:46,
from src/esp8266util.cpp:6:
/home/travis/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_vector.h: In member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const':
.pioenvs/nodemcuv2/FrameworkArduino/Arduino.h:254:18: error: expected unqualified-id before '(' token

You should be able to see the same in the travis CI log.
log.txt

This project runs on esp8266 nodemcu2.

When I dug little deeper I figured that Arduino.h had something it didnt have in the legacy SDK.

//#ifndef _GLIBCXX_VECTOR
// arduino is not compatible with std::vector
//#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
//#endif

Once I commented out the above lines, it worked fine.

I'm not sure if I'm doing something wrong but I do use std::vector in the project.

Let me know if you need further details.

@ivankravets
Copy link
Member

@igrr do you have any ideas?

@igrr
Copy link

igrr commented May 2, 2016

Sure! Including STL headers from the same file which includes "Arduino.h" pretty much doesn't work.

Arduino.h has to provide min and max as defines for compatibility reasons, but alas, that causes issues with STL because there min and max are function names.
There is a ticket filed under our repository which covers this issue, so i think it's out of scope for platformio and may be closed.

Workaround: add #undef min and #undef max after #include <Arduino.h> before you include STL headers.

@supunj
Copy link
Author

supunj commented May 2, 2016

Thanks @igrr and @ivankravets !
that was really quick. For now I'll stick to the workaround and mark this as closed as it is reported elsewhere.

@mithatolut
Copy link

mithatolut commented Jul 23, 2018

had to use

#undef min
#undef max
#include <vector>

to get the compatible min and max ...

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

No branches or pull requests

4 participants