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

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

我尝试执行代码#include quadmath.h #include iostream int main() { char* y = new char[1000]; quadmath_snprintf(y, 1000, %Qf, 1.0q); std::cout y std

我尝试执行代码

#include 

用命令

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++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 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

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/zhonghe/fwq/linux/20201019/11084.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

【免责声明】本站内容转载自互联网,其发布内容言论不代表本站观点,如果其链接、内容的侵犯您的权益,烦请提交相关链接至邮箱xwei067@foxmail.com我们将及时予以处理。

Copygight © 2016-2023 https://www.0532zz.com All Rights Reserved.青岛站长网

站长:xwei067#foxmail.com(请把#换成@)