Hi everyone,
I am encountering a compiler error when I try to build the init module for Assignment 3. The error message says that the "call to 'abs' is ambiguous", with 'abs' being the absolute value function on lines 29, 30, and 31 of init.cpp. Since we are not supposed to change the modules for this assignment, I am not quite sure how to proceed. Has anyone else encountered this error and if so, how did you resolve it?
Thanks in advance. I've included the full error message from Make below:
c++ -std=c++17 -O3 -Wall -g -c -o init.o init.cpp
init.cpp:29:38: error: call to 'abs' is ambiguous
} else if ( (i1==i2 && j1==j2 && abs(k1-k2)==1)
^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:132:6: note: candidate function
int abs(int) __pure2;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:111:39: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:114:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:120:40: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:124:41: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:129:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {
^
init.cpp:30:31: error: call to 'abs' is ambiguous
|| (i1==i2 && abs(j1-j2)==1 && k1==k2)
^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:132:6: note: candidate function
int abs(int) __pure2;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:111:39: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:114:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:120:40: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:124:41: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:129:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {
^
init.cpp:31:21: error: call to 'abs' is ambiguous
|| (abs(i1-i2)==1 && j1==j2 && k1==k2) ) {
^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:132:6: note: candidate function
int abs(int) __pure2;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:111:39: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:114:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:120:40: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:124:41: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h:129:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {
^
3 errors generated.
Make: *** [init.o] Error 1