使用quadmath的G 4.6.3 Linux中的四倍精度

使用quadmath的G 4.6.3 Linux中的四倍精度,第1张

概述我尝试执行代码 #include <quadmath.h>#include <iostream>int main(){ char* y = new char[1000]; quadmath_snprintf(y, 1000, "%Qf", 1.0q); std::cout << y << std::endl; return 0;} 用命令 g++ test.cpp -o t 我尝试执行代码

#include <quadmath.h>#include <iostream>int main(){  char* y = new char[1000];  quadmath_snprintf(y,1000,"%Qf",1.0q);  std::cout << y << std::endl;  return 0;}

用命令

g++ test.cpp -o test

我收到错误:

/tmp/cctqto7E.o: In function `main':test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*,unsigned int,char const*,...)'collect2: ld returned 1 exit status

版本是:

g++ --versiong++ (Ubuntu/linaro 4.6.3-1ubuntu5) 4.6.3copyright (C) 2011 Free Software Foundation,Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABIliTY or fitness FOR A PARTI@R_404_6603@R PURPOSE.

我该如何解决这个问题?

解决方法 我看到了同样的行为:

~/Coding/q$g++ test.cpp -lquadmath/tmp/ccYdHwL5.o: In function `main':test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*,...)'collect2: ld returned 1 exit status

一种解决方法是使用此模式包含标头:

extern "C" {#include "quadmath.h"}

之后:

~/Coding/q$g++ test.cpp -lquadmath~/Coding/q$./a.out 1.000000
总结

以上是内存溢出为你收集整理的使用quadmath的G 4.6.3 Linux中的四倍精度全部内容,希望文章能够帮你解决使用quadmath的G 4.6.3 Linux中的四倍精度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1030791.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存