根据cppreference,函数
我收到了以下错误消息:
我错过了什么?我是否误读了cppreference?
acosl
应该在std名称空间中:https://en.cppreference.com/w/cpp/numeric/math/acos
然而,在使用gcc(或clang)时,下面的代码无法编译:#include <cmath>
int main()
{
long double var = std::acosl(4.0);
return 0;
}
我收到了以下错误消息:
gay@latitude-7490:~$ g++ -std=c++11 test.cpp
test.cpp: In function 'int main()':
test.cpp:5:26: error: 'acosl' is not a member of 'std'; did you mean 'acosh'?
5 | long double truc = std::acosl( (long double)4.0);
| ^~~~~
| acosh
我错过了什么?我是否误读了cppreference?
acosl(4.0)
和std::acos(4.0l)
都可以工作。此外,在Clang中添加-stdlib=libc++
可以使std::acosl(4.0)
正常工作。 - HolyBlackCat