M_PI不适用于gcc --std = c11,但使用--std = gnu11? [英] M_PI not available with gcc --std=c11 but with --std=gnu11?
问题描述
我注意到 M_PI
在 c11
中不可用。通过查看 /usr/include/math.h
我可以看到 M_PI
是在以下情况下定义的:
#if!defined(__ STRICT_ANSI__)|| ((_XOPEN_SOURCE_0)> = 500)
...
#define M_PI 3.1415 ...
#endif
此外,在 math.h from glibc 在 其中 顺便说一句, GCC 4.9与<$ c一起使用时$ c> -std = c99 没有定义 I noticed Moreover in the What is the story in between Which By the way, It's simple: C compilers cannot introduce such constants without breaking legal C programs (the name is not reserved, and could be used as an identifier), and as such, they are only defined as an extension. GCC 4.9 when used with 这篇关于M_PI不适用于gcc --std = c11,但使用--std = gnu11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! __ STRICT_ANSI __
被替换为
__ USE_MISC
。我完全失去了这一点。
- std = c11
和中定义的常数之间有什么关系? math.h
?
libc
应该考虑 debian
distribution?
M_PI
在 c99
和 gnu11
... M_PI
未在标准C中定义。如果您希望符合标准,请提供您自己的定义。
M_PI
,但是与 -std = gnu99
一起使用时可以做到这一点M_PI
is unavailable on c11
. By looking at /usr/include/math.h
I can see M_PI
is defined if: #if !defined(__STRICT_ANSI__) || ((_XOPEN_SOURCE - 0) >= 500)
...
#define M_PI 3.1415...
#endif
math.h
from glibc __STRICT_ANSI__
is replaced with __USE_MISC
. I am completely lost with this. --std=c11
and the constants defined in math.h
?libc
should I consider on a debian
distribution ?M_PI
is defined in c99
and gnu11
...M_PI
is not defined in standard C. Provide your own definition if you want to be standard-compliant.-std=c99
doesn't define M_PI
, but does when used with -std=gnu99