C++ c++;gcc错误:';sqrtl';不是';std&x27;

C++ c++;gcc错误:';sqrtl';不是';std&x27;,c++,gcc,std,cmath,C++,Gcc,Std,Cmath,当我试图编译以下程序时,编译器给出错误:“sqrtl”不是“std”的成员。 #include <cmath> #include <iostream> int main(){ std::cout << std::sqrtl(5.0) << "\n"; return 0; } #包括 #包括 int main(){ std::cout这是一个bug。Persqrtl是std命名空间的成员 这是法律法规,将在和中编译 有一个问题,但它

当我试图编译以下程序时,编译器给出
错误:“sqrtl”不是“std”的成员。

#include <cmath>
#include <iostream>
int main(){
    std::cout << std::sqrtl(5.0) << "\n";
    return 0;
}
#包括
#包括
int main(){
std::cout这是一个bug。Per
sqrtl
std
命名空间的成员

这是法律法规,将在和中编译


有一个问题,但它还没有得到解决,因为它非常琐碎,而且资源有限。

您使用的是什么版本的gcc?您需要启用c++11支持吗?如果有疑问,您可以查看它。删除
std::
的原因可能是因为它回到了c提供的标准函数。注意:at
std::sqrt
有几个重载,将使用正确的“版本”对于所提供的类型,@Slava Woot,MSV今天赢得了一致性竞赛:@Amadeus谢谢。我忘了编译器资源管理器对clang和gcc都使用libstdc++。Wandbox对clang使用libc++,而libc++没有这个bug。这是否意味着我无法访问@FrançoisAndrieux ment注释中的
std::sqrtl
sqrtl
的函数回到了C提供的标准函数。这有什么区别吗?@SmileyCraft这意味着在gcc中你不能使用
std::sqrtl
,因为他们还没有实现它。你可以只使用
sqrtl
。@SmileyCraft你可以使用
std::sqrt
,它将使用正确的函数参数类型的重载。如果确实要显式使用
sqrtl
可以通过使用
std::sqrt
并将参数强制转换为
long double
或使用
long double
文字来替代使用C中的全局作用域函数。
std::sqrt(5.0l)
std::sqrt(static_cast(5.0))
工作。
namespace std {
      [...]
      float sqrt(float x);  // see [library.c]
      double sqrt(double x);
      long double sqrt(long double x);  // see [library.c]
      float sqrtf(float x);
      long double sqrtl(long double x);
      [...]
}