-
Notifications
You must be signed in to change notification settings - Fork 7.6k
cores: replace max and min macros with imports from std #1783
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
Conversation
TravisCI is unhappy. I tried the two examples from AzureIoT library locally (Arduino IDE 1.8.5 on Windows), and they all build correctly. I couldn't figure out what's wrong. |
Looks like the problem is a redefinition of
|
There's a usage of Looks like I also need to replace |
I’ve completed the |
Hey! Thanks for going through this :) It was somewhere on the list of things to do... |
hi, we got this issue, the test code is below:
this code will got error: we think this change cause this issue: |
In C++, |
* Other Arduino cores uses a macro to redefine libc abs() to take any type, meaning abs(-3.3) == 3.3 not the normal libc result of 3. * 1e4bf14 (espressif#1783) replaced similar min, max macros with c++ stdlib. However this change includes <algorithm> after the line which defines the abs() macro. <algorithm> includes <cstdlib> which undefines abs() and re-defines it. * This means abs() becomes the plain libc version again which only takes integers, so abs(-3.3) == 3. As reported here: espressif/esp-idf#3405 This fix tries to keep in the spirit of espressif#1783 by using libstdc++. The other option would be to include <cstdlib> before defining the abs() macro, so it doesn't get undef-ed again later on.
* Other Arduino cores uses a macro to redefine libc abs() to take any type, meaning abs(-3.3) == 3.3 not the normal libc result of 3. * 1e4bf14 (#1783) replaced similar min, max macros with c++ stdlib. However this change includes <algorithm> after the line which defines the abs() macro. <algorithm> includes <cstdlib> which undefines abs() and re-defines it. * This means abs() becomes the plain libc version again which only takes integers, so abs(-3.3) == 3. As reported here: espressif/esp-idf#3405 This fix tries to keep in the spirit of #1783 by using libstdc++. The other option would be to include <cstdlib> before defining the abs() macro, so it doesn't get undef-ed again later on.
fixes #1734