Closed llvmbot closed 11 years ago
My mistake; I missed the macro preprocessor that declares the namespace (namely _LIBCPP_BEGIN_NAMESPACE_STD); I was comforted in y wrong assessment by some std:: in the file but they were all before the macro)
Thanks a lot for your quick reply,
Best regards,
Sebastien
I just preprocessed
libstdc++ produces:
namespace std {
inline double abs(double x) { return builtin_fabs(__x); }
inline float abs(float x) { return builtin_fabsf(__x); }
inline long double abs(long double x) { return builtin_fabsl(__x); }
}
libc++ produces:
namespace std {inline namespace __1 {
inline attribute ((visibility("hidden"), __always_inline)) float abs(float x) throw() {return fabsf(__x);}
inline attribute ((visibility("hidden"), __always_inline)) double abs(double x) throw() {return fabs(__x);}
inline attribute ((visibility("hidden"), __always_inline)) long double abs(long double x) throw() {return fabsl(__x);}
} }
Neither
int main() { abs(1.0); }
test.cpp:5:5: error: use of undeclared identifier 'abs'; did you mean 'fabs'? abs(1.0); ^~~ fabs
Extended Description
I'm trying to compile a library with clang and libc++, and stumble upon many name conflicts as this library has redefined functions named "abs", "norm", etc... in the global namespace.
This library (named Freefem++) compiles well with libstdc++; I had a quick look and I am under the impress that the difference is in cmath header file: in libstdc++ the abs function is in std namespace whereas in libc++ it is in global one.
Am I right in my assessment, and if so which library complies with the C++ standard on that point?
Best regards,
Sebastien Gilles