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

Use std::abs for a float-compatible abs() function #2738

Merged
merged 1 commit into from
May 11, 2019

Commits on May 3, 2019

  1. Use std::abs for a float-compatible abs() function

    * 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.
    projectgus committed May 3, 2019
    Configuration menu
    Copy the full SHA
    4a2bf44 View commit details
    Browse the repository at this point in the history