delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/05/02:06:43

Date: Thu, 5 Oct 2000 08:05:07 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Michael Powe <michael+netscape AT trollope DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: problem with math.h
In-Reply-To: <39DC061F.97DFBB0D@trollope.org>
Message-ID: <Pine.SUN.3.91.1001005075934.3958F-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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