Newton Solver std::abs() error in compiling on MacOSX 10.11.3

Issue #646 resolved
Daniele Tartarini (danielta) created an issue

on Mac OSX 10.11.3 with C/C++ compiler: AppleClang 7.0.2.7000181

Compiling branch master or next I get:

[ 22%] Building CXX object dolfin/CMakeFiles/dolfin.dir/nls/NewtonSolver.cpp.o
/Users/FENICS/dolfin_src/dolfin/nls/NewtonSolver.cpp:164:9: error: call to 'abs' is ambiguous
    if (std::abs(1.0 - relaxation) < DOLFIN_EPS)
        ^~~~~~~~
/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:159:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:161:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
1 error generated.

It works when adding:

 #include<cmath> 

Comments (2)

  1. Log in to comment