gpt4 book ai didi

c - M_PI 不适用于 gcc --std=c11 但 --std=gnu11?

转载 作者:太空狗 更新时间:2023-10-29 16:51:38 30 4
gpt4 key购买 nike

我注意到 M_PIc11 上不可用。通过查看 /usr/include/math.h 我可以看到 M_PI 定义为:

#if !defined(__STRICT_ANSI__) || ((_XOPEN_SOURCE - 0) >= 500)
...
#define M_PI 3.1415...
#endif

此外在来自 glibcmath.h__STRICT_ANSI__ 替换为 __USE_MISC。我对此完全迷失了。

--std=c11math.h 中定义的常量之间有什么故事?

debian 发行版中我应该考虑使用哪个 libc

顺便说一句,M_PIc99gnu11中定义...

最佳答案

很简单:M_PI 未在标准 C 中定义。如果您想符合标准,请提供您自己的定义。

C 编译器不能在不破坏合法 C 程序的情况下引入此类常量(名称未保留,可用作标识符),因此,它们仅定义为扩展。

GCC 4.9 when used with -std=c99 doesn't define M_PI , 但是 does when used with -std=gnu99

关于c - M_PI 不适用于 gcc --std=c11 但 --std=gnu11?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29264462/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com