AcademySoftwareFoundation / Imath

Imath is a C++ and python library of 2D and 3D vector, matrix, and math operations for computer graphics
https://imath.readthedocs.io
BSD 3-Clause "New" or "Revised" License
356 stars 104 forks source link

3.1.10 broken `isfinite`: `ImathFun.cpp: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?` #367

Closed barracuda156 closed 4 months ago

barracuda156 commented 4 months ago

I recall this has been fixed in OpenEXR, but now apparently broken here by a recent commit https://github.com/AcademySoftwareFoundation/Imath/commit/0e0f4a732ceaeeacc86d289610b7278d46963f78

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp: In function 'float Imath_3_1::succf(float)':
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp:13:12: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?
   13 |     return isfinite(f) ?
      |            ^~~~~~~~
      |            std::isfinite
In file included from /opt/local/include/LegacySupport/cmath:54,
                 from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp:7:
/opt/local/include/gcc13/c++/cmath:1138:5: note: 'std::isfinite' declared here
 1138 |     isfinite(_Tp __x)
      |     ^~~~~~~~
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp: In function 'float Imath_3_1::predf(float)':
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp:19:12: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?
   19 |     return isfinite(f) ?
      |            ^~~~~~~~
      |            std::isfinite
/opt/local/include/gcc13/c++/cmath:1138:5: note: 'std::isfinite' declared here
 1138 |     isfinite(_Tp __x)
      |     ^~~~~~~~
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp: In function 'double Imath_3_1::succd(double)':
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp:25:12: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?
   25 |     return isfinite(d) ?
      |            ^~~~~~~~
      |            std::isfinite
/opt/local/include/gcc13/c++/cmath:1138:5: note: 'std::isfinite' declared here
 1138 |     isfinite(_Tp __x)
      |     ^~~~~~~~
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp: In function 'double Imath_3_1::predd(double)':
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_imath/imath/work/imath-3.1.10/src/Imath/ImathFun.cpp:31:12: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?
   31 |     return isfinite(d) ?
      |            ^~~~~~~~
      |            std::isfinite
/opt/local/include/gcc13/c++/cmath:1138:5: note: 'std::isfinite' declared here
 1138 |     isfinite(_Tp __x)
      |     ^~~~~~~~
make[2]: *** [src/Imath/CMakeFiles/Imath.dir/ImathFun.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
barracuda156 commented 4 months ago

@kdt3rd Could you please take a look? I get a similar breakage here to an earlier one in OpenEXR (which you have fixed there): https://github.com/AcademySoftwareFoundation/openexr/issues/1412

barracuda156 commented 4 months ago

Is it appropriate to prepend these with std:: here as well, as GCC suggests?

jmroot commented 4 months ago

It's not clear which C++ standard Imath is intended to require, but std::isfinite was added in C++11. In older C++, you should usually be able to use isfinite if you #include <math.h> since it's part of C99.

If requiring C++11 is the intent, then CMakeLists.txt should declare that requirement by setting CMAKE_CXX_STANDARD.