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

Please use std::fabs instead of just fabs in C++ to avoid conflicts #116

Open
yurivict opened this issue May 25, 2019 · 0 comments
Open

Comments

@yurivict
Copy link

clang-8 compiler complains about fabs on BSDs:

In file included from codons.cpp:1:
In file included from ./codons.h:3:
In file included from ./GBase.h:13:
/usr/include/c++/v1/math.h:761:41: error: no member named 'fabsf' in the global namespace; did you mean 'fabs'?
abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
                                      ~~^
/usr/include/math.h:255:8: note: 'fabs' declared here
double  fabs(double) __pure2;
        ^
In file included from codons.cpp:1:
In file included from ./codons.h:3:
In file included from ./GBase.h:13:
/usr/include/c++/v1/math.h:769:47: error: no member named 'fabsl' in the global namespace; did you mean 'fabs'?
abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
                                            ~~^
/usr/include/math.h:255:8: note: 'fabs' declared here
double  fabs(double) __pure2;
        ^

Same with all other mathematical functions. They are safer when invoked from the std:: namespace.

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

No branches or pull requests

1 participant