Skip to content

Include Arduino.h AFTER memory.h #1440

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

Merged
merged 2 commits into from
Jan 18, 2016
Merged

Include Arduino.h AFTER memory.h #1440

merged 2 commits into from
Jan 18, 2016

Conversation

stefangordon
Copy link
Contributor

Arduino.h defines min/max which are then redefined with templates in stl_algobase.h imported from memory.h. This is the least impactful way I can find to get past this for now and unblock use of wificlient in more scenarios.

I haven't yet figured out how this is sometimes working just fine in simple scenarios, but very often any use of WifiClient.h will make it impossible to compile due to conflicting with the other definitions of min/max.

I'm using IDE 1.6.7. This unblocks use of WifiClient and WifiSecureClient successfully for me and shouldn't have negative impacts.

Arduino.h defines min/max which are then redefined with templates in stl_algobase.h imported from memory.h.  This is the least impactful way I can find to get past this for now and unblock use of wificlient in more scenarios.
@stefangordon
Copy link
Contributor Author

This is what a failure looks like prior to the fix

In file included from c:\program files (x86)\arduino\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\memory:62:0,

                 from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClient.h:28,

                 from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClientSecure.h:25,


c:\program files (x86)\arduino\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:240:56: error: macro "min" passed 3 arguments, but takes just 2

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

                                                        ^

c:\program files (x86)\arduino\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:261:56: error: macro "max" passed 3 arguments, but takes just 2

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

igrr added a commit that referenced this pull request Jan 18, 2016
Include Arduino.h AFTER memory.h
@igrr igrr merged commit a39b482 into esp8266:master Jan 18, 2016
@vlast3k
Copy link

vlast3k commented Feb 2, 2016

Somehow, after this submit, i cannot compile with Arduino 1.6.5, it fails with the following issues
I am not tied to 1.6.7, just that as i had got it - up to now 1.6.5 was recommended to use

c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\limits:987:7: error: constexpr static data member 'min' must have an initializer
       min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; }
       ^
c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\limits:987:7: error: expected ';' at end of member declaration
In file included from c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:59:0,
                 from c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\memory:62,
                 from C:\develop\arduino_tool\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClient.h:24,
                 from C:\develop\arduino_tool\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39,
                 from ESP8266_SerialOTATS.ino:1:
c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\limits:987:13: error: expected unqualified-id before 'noexcept'
       min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; }
             ^
In file included from c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\random:43:0,
                 from c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:65,
                 from c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62,
                 from ESP8266_SerialOTATS.ino:9:
c:\develop\arduino_tool\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\limits:990:7: error: constexpr static data member 'max' must have an initializer
       max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; }
       ^

and other simillar issues.

@stefangordon
Copy link
Contributor Author

It is certainly worth trying with 1.6.8 (nightly) as 1.6.7 and before have a variety of incompatibilities (arduino/arduino-builder#68). In the likely event that doesn't help we'll need to look for a better way to fix this as we will keep finding scenarios where Arduino.h min/max clobber SDK definitions.

Also does it repro in a relatively simple example? If so perhaps share one and I can investigate.

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

Successfully merging this pull request may close these issues.

3 participants