Mail Archives: djgpp/2000/10/05/02:06:43
On Wed, 4 Oct 2000, Michael Powe wrote:
> gcc -Wall -ansi -pedantic ... -lm
>
> results in an error that `PI' is undeclared.
This is the expected behavior.
> Looking in math.h, I see that the section in which PI is #defined is
> preceded by #ifndef __STRICT_ANSI__ and #ifndef _POSIX_SOURCE.
>
> Does ANSI C exclude a value for PI?
Yes, the ANSI Standard does not define any macro to get the value of Pi.
Since PI and M_PI pollute the namespace (they do not begin with an
underscore), they are made invisible with -ansi.
Portable programs which comply to ANSI C should provide their own
definitions of Pi. You could simply copy the value from math.h.
- Raw text -