使用长双 [英] use of long double

查看:77
本文介绍了使用长双的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gcc中使用long double类型的数学函数?我在源代码中使用了powl并探索了

(包括math.h)但我得到了未定义的引用

`_powl''当我尝试编译时:


gcc -o 1_1prog 1_1prog.c -lm


我也试过-ansi和-std = c99但仍然得到了同样的信息。

有人有什么想法吗?


非常感谢!


Ryan

How to use math functions of type long double in gcc? I used powl and expl
in my source code (and included math.h) but I got "undefined reference to
`_powl''" when I tried to compile it with:

gcc -o 1_1prog 1_1prog.c -lm

I also tried "-ansi" and "-std=c99" but still got the same message. Does
anyone have any idea?

Thanks a lot!

Ryan

推荐答案

Ryan Lee写道:
Ryan Lee wrote:
如何在gcc中使用long double类型的数学函数?我在源代码中使用了powl并探讨了
(包括math.h),但我得到了未定义的引用
`_powl''当我尝试编译时:

gcc -o 1_1prog 1_1prog.c -lm

我也试过-ansi和-std = c99但仍然得到了同样的信息。是否有人有任何想法?

非常感谢!

Ryan
How to use math functions of type long double in gcc? I used powl and expl
in my source code (and included math.h) but I got "undefined reference to
`_powl''" when I tried to compile it with:

gcc -o 1_1prog 1_1prog.c -lm

I also tried "-ansi" and "-std=c99" but still got the same message. Does
anyone have any idea?

Thanks a lot!

Ryan



powl()提供(或不)由您的系统上安装的libm。如果您的

库没有包含它,您必须自己提供它(并将

原型添加到< math.h>)。写i386

处理器并不难。 expl()可以提供< mathinline.h>对于这样的

处理器。 -ansi可能意味着C89,提供长双倍数学

函数是可选的,并且因平台而异。这些选项不会导致

gcc更改其库选择,或者在互联网上查看

以获得符合您需求的内容。

-

Tim Prince


powl() is provided (or not) by the libm installed on your system. If your
library doesn''t include it, you must provide it yourself (and add the
prototypes to <math.h>). It''s not too difficult to write for i386
processors. expl() could be provided with a <mathinline.h> for such
processors. -ansi probably means C89, where provision of long double math
functions is optional, and varies by platform. These options don''t cause
gcc to change its selection of libraries, or go out looking on the Internet
for something matching your desire.
--
Tim Prince


Tim Prince< ti *********** @ xxxxsbcglobal.net>写道:
Tim Prince <ti***********@xxxxsbcglobal.net> wrote:
Ryan Lee写道:
Ryan Lee wrote:
如何在gcc中使用long double类型的数学函数?我在源代码中使用了powl并探讨了
(包括math.h),但我得到了未定义的引用
`_powl''当我尝试编译时:

gcc -o 1_1prog 1_1prog.c -lm

我也试过-ansi和-std = c99但仍然得到了同样的信息。是否有人知道?
由系统上安装的libm提供(或不提供)powl()。
How to use math functions of type long double in gcc? I used powl and expl
in my source code (and included math.h) but I got "undefined reference to
`_powl''" when I tried to compile it with:

gcc -o 1_1prog 1_1prog.c -lm

I also tried "-ansi" and "-std=c99" but still got the same message. Does
anyone have any idea?
powl() is provided (or not) by the libm installed on your system.




在C99中,它必须存在。在C89中,当你要求ISO C模式时,它不被允许(或者至少是

)。


如果GCC及其libs即使在C99模式下也不提供powl(),它们可能是不完整的
。在Gnu组中询问是否有一个版本可以提供C99数学函数,或者是否需要以其他方式调用GCC一些



如果您的图书馆没有包含它,您必须自己提供(并将原型添加到< math.h>)。


使用系统头文件进行清理是绝对不明智的。写下你的

自己的额外标题。

为i386
处理器编写起来并不困难。 expl()可以提供一个< mathinline.h>



In C99, it must be present. In C89, it isn''t allowed to be (or at least,
not when you ask for ISO C mode).

If GCC and its libs don''t provide powl() even in C99 mode, they may be
incomplete. Ask in a Gnu group whether there is a version that does
provide the C99 math functions, or whether you need to invoke GCC some
other way.
If your library doesn''t include it, you must provide it yourself (and
add the prototypes to <math.h>).
It is never wise to muck about with the system header files. Write your
own additional header.
It''s not too difficult to write for i386
processors. expl() could be provided with a <mathinline.h>




By _what_?这不是ISO C标题。


Richard



By _what_? That''s not an ISO C header.

Richard


Richard Bos< rl *@hoekstra-uitgeverij.nl> ;写道:
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
Tim Prince< ti *********** @ xxxxsbcglobal.net>写道:
Tim Prince <ti***********@xxxxsbcglobal.net> wrote:
Ryan Lee写道:
Ryan Lee wrote:
>如何在gcc中使用long double类型的数学函数?我用过powl并探索了
>在我的源代码中(包括math.h)但我得到了未定义的引用
> `_powl"当我尝试编译它时:
>
> gcc -o 1_1prog 1_1prog.c -lm
>
>我也试过-ansi和-std = c99但仍然得到了同样的信息。是
>任何人都有任何想法吗?
由系统上安装的libm提供(或不提供)powl()。
> How to use math functions of type long double in gcc? I used powl and expl
> in my source code (and included math.h) but I got "undefined reference to
> `_powl''" when I tried to compile it with:
>
> gcc -o 1_1prog 1_1prog.c -lm
>
> I also tried "-ansi" and "-std=c99" but still got the same message. Does
> anyone have any idea?
powl() is provided (or not) by the libm installed on your system.




正确。

在C99中,它必须存在。在C89中,不允许(或者至少,当你要求ISO C模式时)。


对托管编译器来说是真的。对于独立编译器来说是假的。

如果GCC及其库不提供powl(),即使在C99模式下,它们也可能不完整。在Gnu小组中询问是否有一个版本提供C99数学函数,或者是否需要以其他方式调用GCC。



Correct.

In C99, it must be present. In C89, it isn''t allowed to be (or at least,
not when you ask for ISO C mode).
True for hosted compilers. False for freestanding compilers.

If GCC and its libs don''t provide powl() even in C99 mode, they may be
incomplete. Ask in a Gnu group whether there is a version that does
provide the C99 math functions, or whether you need to invoke GCC some
other way.




GCC本身只是一个独立的编译器,因此不包括任何数学库(也很少有其他库)。

GCC使用任何可用的库在主机上,所以是那些提供必须与之交谈的人(或者自己安装一些合适的

第三方库实现的人)。


-

<在这里插入你最喜欢的报价。>

Erik Trulsson
呃****** @ student.uu.se


这篇关于使用长双的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆