www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/18/11:15:10

Sender: tim AT riker DOT skynet DOT be
Message-ID: <3B2E1AA0.7F32571A@falconsoft.be>
Date: Mon, 18 Jun 2001 17:13:36 +0200
From: Tim Van Holder <tim DOT vanholder AT falconsoft DOT be>
Organization: Anubex N.V.
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.4-win4lin i686)
X-Accept-Language: en, nl-BE, nl
MIME-Version: 1.0
To: Patrick Mitran <pmitran AT tsp DOT ece DOT mcgill DOT ca>
CC: djgpp AT delorie DOT com
Subject: Re: M_PI and -ansi
References: <TMoX6.1671$Ug2 DOT 550858 AT carnaval DOT risq DOT qc DOT ca>
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019