Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add <cmath> header to fix ambiguity for abs #633

Conversation

sloede
Copy link

@sloede sloede commented Dec 29, 2023

While trying to build OpenFHE using BinaryBuilder.jl, I received some method ambiguity errors for the use of abs on macOS, on both aarch64 (log) and x86_64 (log):

In file included from /workspace/srcdir/openfhe-development/src/core/lib/utils/utilities.cpp:36:
/workspace/srcdir/openfhe-development/src/core/include/utils/utilities.h:118:12: error: call to 'abs' is ambiguous
    return std::abs(d) > static_cast<double>(Max64BitValue());
           ^~~~~~~~
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
In file included from /workspace/srcdir/openfhe-development/src/core/lib/utils/utilities.cpp:36:
/workspace/srcdir/openfhe-development/src/core/include/utils/utilities.h:135:16: error: call to 'abs' is ambiguous
        return std::abs(d) <= static_cast<double>(std::numeric_limits<int32_t>::max());
               ^~~~~~~~
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
In file included from /workspace/srcdir/openfhe-development/src/core/lib/utils/utilities.cpp:36:
/workspace/srcdir/openfhe-development/src/core/include/utils/utilities.h:137:16: error: call to 'abs' is ambiguous
        return std::abs(d) <= static_cast<double>(Max64BitValue());
               ^~~~~~~~
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
3 errors generated.

By including <cmath> in src/core/include/utils/utilities.h, this error seems to be fixed.

@dsuponitskiy
Copy link
Collaborator

We encourage all OpenFHE users to post their questions and suggestions to this forum.
For this particular case, I have opened a new issue and mentioned this PR in its description.

@sloede
Copy link
Author

sloede commented Jan 4, 2024

Thanks! My personal experience is that a PR with a concrete change set is often more descriptive than a prose description in a forum, but I'll try to follow the proper procedure next time.

What about the already existing PR #634? Any chance you could have a look at this as well? Please let me know if I should do anything to it to make it easier for the maintainers (e.g., change the target to dev etc.)

@sloede sloede deleted the msl/fix-stdlib-ambiguity-for-abs-on-macos branch January 4, 2024 06:20
@dsuponitskiy
Copy link
Collaborator

This issue (to include ) was more urgent (like a bug) as it prevented you from building the libraries, so I tried to fix it asap. At the moment I am not sure how we are going to proceed with PR #634. I would need to discuss this with my colleague(s) first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants