AlloSphere-Research-Group / allolib

Library for interactive multimedia application development
BSD 3-Clause "New" or "Revised" License
36 stars 14 forks source link

explicit cast argument to std::abs() in al_Functions.hpp to avoid amb… #1

Closed grrrwaaa closed 6 years ago

grrrwaaa commented 6 years ago

…iguous type error in clang on osx.

The cmake settings and the build errors were as follows:

-- The C compiler identification is AppleClang 6.1.0.6020053 -- The CXX compiler identification is AppleClang 6.1.0.6020053 -- Check for working C compiler: /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done MACOS -- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- Found GLEW: /usr/local/include
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") -- Checking for one of the modules 'glfw3' -- Checking for module 'libassimp' -- No package 'libassimp' found -- Assimp 3 found found freeimage found assimp found freetype Using RtMidi Using RtAudio -- Configuring done -- Generating done

...

make

...

In file included from /Users/grrrwaaa/code/allolib/src/util/al_Array.cpp:2: In file included from /Users/grrrwaaa/code/allolib/include/al/util/al_Array.hpp:49: /Users/grrrwaaa/code/allolib/include/al/core/math/al_Functions.hpp:471:10: error: call to 'abs' is ambiguous return std::abs(ai - bi) <= maxULP; ^~~~ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:660:1: note: candidate function abs(float x) _NOEXCEPT {return fabsf(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:664:1: note: candidate function abs(double x) _NOEXCEPT {return fabs(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:668:1: note: candidate function abs(long double x) _NOEXCEPT {return fabsl(__x);} ^ In file included from /Users/grrrwaaa/code/allolib/src/util/al_Array.cpp:2: In file included from /Users/grrrwaaa/code/allolib/include/al/util/al_Array.hpp:49: /Users/grrrwaaa/code/allolib/include/al/core/math/al_Functions.hpp:484:10: error: call to 'abs' is ambiguous return std::abs(ai - bi) <= maxULP; ^~~~ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:660:1: note: candidate function abs(float x) _NOEXCEPT {return fabsf(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:664:1: note: candidate function abs(double x) _NOEXCEPT {return fabs(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:668:1: note: candidate function abs(long double x) _NOEXCEPT {return fabsl(x);} ^ In file included from /Users/grrrwaaa/code/allolib/src/util/al_Array.cpp:2: In file included from /Users/grrrwaaa/code/allolib/include/al/util/al_Array.hpp:49: /Users/grrrwaaa/code/allolib/include/al/core/math/al_Functions.hpp:674:11: error: call to 'abs' is ambiguous int M = std::abs((int)m); // M = |m| ^~~~ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:660:1: note: candidate function abs(float __x) _NOEXCEPT {return fabsf(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:664:1: note: candidate function abs(double x) _NOEXCEPT {return fabs(x);} ^ /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:668:1: note: candidate function abs(long double x) _NOEXCEPT {return fabsl(x);} ^ 3 errors generated. make[2]: [CMakeFiles/al.dir/src/util/al_Array.cpp.o] Error 1 make[1]: [CMakeFiles/al.dir/all] Error 2 make: *** [all] Error 2