Mail Archives: djgpp/2001/06/18/11:15:10
Patrick Mitran wrote:
>
> Hi,
>
> when I compile with the -ansi switch, it seems that I don't have a
> predefined
> constant for PI in math.h. This can easily be fixed by defining my own
> constant as
>
> const real pi = 3.14159265358979323846;
>
> However, I believe this is bad style. What would be a good way of getting
> a numerically accurate value of PI that is ANSI compliant?
There isn't - the reason M_PI isn't defined if you use -ansi is that
M_PI isn't in the ANSI spec. It might be in the C99 standard, but DJGPP
and gcc aren't c99-compliant (yet).
A good way around this is not to use -ansi. If you use -pedantic, it
will not restrict available defines/functions/variables to those
provided by the ANSI spec, but it will generate warnings if you use
things ANSI won't allow (and -pedantic-errors will generate errors).
Unless you're restricted to using only things the ANSI spec provides,
using -ansi is not required.
--
Tim Van Holder - Anubex N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.
- Raw text -