I noticed 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
Moreover in the math.h
from glibc __STRICT_ANSI__
is replaced with __USE_MISC
. I am completely lost with this.
What is the story in between --std=c11
and the constants defined in math.h
?
Which libc
should I consider on a debian
distribution ?
By the way, M_PI
is defined in c99
and gnu11
...
It's simple: M_PI
is not defined in standard C. Provide your own definition if you want to be standard-compliant.
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 -std=c99
doesn't define M_PI
, but does when used with -std=gnu99