1

When using cmath in Mac OS Catalina along with PCL Library I have to do the change proposed in https://stackoverflow.com/a/61519060/6131111

2. Using #include</Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h> instead of <math.h> in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath

in order to avoid the following errors:

In file included from /Users/hectoresteban/Documents/C++/SensorFusion/SFND_Lidar_Obstacle_Detection/src/sensors/../render/render.h:7:
In file included from /usr/local/include/pcl-1.9/pcl/visualization/pcl_visualizer.h:42:
In file included from /usr/local/include/pcl-1.9/pcl/correspondence.h:46:
In file included from /usr/local/include/eigen3/Eigen/StdVector:14:
In file included from /usr/local/include/eigen3/Eigen/Core:96:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:245:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)

If I change this import then I can run PCL, but now I cannot run any normal script that I develop that imports cmath.h as I get the following errors:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:760:41: error: no member named 'fabsf' in the global namespace; did you mean 'labs'?
abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
                                      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h:148:7: note: 'labs' declared here
long     labs(long) __pure2;
         ^
In file included from /Users/hectoresteban/Documents/C++/SensorFusion/SFND_2D_Feature_Tracking/src/matching2D_Student.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/numeric:148:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:304:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:764:42: error: no member named 'fabs' in the global namespace
abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
                                       ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:768:47: error: no member named 'fabsl' in the global namespace
abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
                                            ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:774:93: error: no member named 'acosf' in the global namespace; did you mean 'acos'?
inline _LIBCPP_INLINE_VISIBILITY float       acos(float __lcpp_x) _NOEXCEPT       {return ::acosf(__lcpp_x);}
                                                                                          ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:774:46: note: 'acos' declared here
inline _LIBCPP_INLINE_VISIBILITY float       acos(float __lcpp_x) _NOEXCEPT       {return ::acosf(__lcpp_x);}
                                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:775:93: error: no member named 'acosl' in the global namespace; did you mean 'acos'?
inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
                                                                                          ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:774:46: note: 'acos' declared here
inline _LIBCPP_INLINE_VISIBILITY float       acos(float __lcpp_x) _NOEXCEPT       {return ::acosf(__lcpp_x);}

Then I have to contantly change the math.h import in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath depending on what I am working. Do you have any solution?

Hector Esteban
  • 1,011
  • 1
  • 14
  • 29

0 Answers0