[Developers] Re: [Aeidevelopment] CVS: "AEIDevelopment/ADMMass/src volume_integral.c"
benger at zib.de
Thu Oct 6 10:02:36 CDT 2005
Well, for instance under Windows <math.h> does not define M_PI .
#define M_PI 4.0*atan(1.0)
does not sound like a good alternative, since then you get a slow
function call instead of a compile-time constant (except that there
is an hyper-intelligent compiler that calls possibly user-defined
functions at compile-time).
On Thu, Oct 06, 2005 at 11:51:28AM +0200, Jonathan Thornburg wrote:
> [[how to get $\pi$ as a compile-time constant in C code]]
> I suggested
> | Why not just use M_PI (defined by <math.h>, which you've already
> | included)?
> | Are there systems whose <math.h> doesn't define M_PI?
> On Thu, 6 Oct 2005, Frank Loeffler wrote:
> >Concerning this, and probably an error of mine: Lately I tries to compile
> >Cactus with gcc4.0.1, and the option std=c99. This resulted in an
> >undefined M_PI, even if math.h was included. Do you know why?
> I should have checked the FAQ. Quoting from
> : Question 14.8
> : The pre-#defined constant M_PI seems to be missing from my machine's copy
> : of <math.h>.
> : That constant (which is apparently supposed to be the value of pi,
> : to the machine's precision), is not standard. If you need pi, you'll have
> : to #define it yourself.
> : References: PCS Sec. 13 p. 237
> The reference points to
> Mark R. Horton, Portable C Software, Prentice Hall, 1990, ISBN
> So apparently M_PI is just a "common extension", not part of the C
> standard. So... gcc 4.* tries to be more standard-conforming, and
> evidently in C99 mode it's trying to avoid tromping on the user namespace
> with macros like M_PI.
> There's always 4.0*atan(1.0).
> -- Jonathan Thornburg <jthorn at aei.mpg.de>
> Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut),
> Golm, Germany, "Old Europe" http://www.aei.mpg.de/~jthorn/home.html
> "Washing one's hands of the conflict between the powerful and the
> powerless means to side with the powerful, not to be neutral."
> -- quote by Freire / poster by Oxfam
> Developers mailing list
> Developers at cactuscode.org
Dr. Werner Benger <benger at zib.de, Werner.Benger at aei.mpg.de>
Zuse Institute Berlin ZIB
Takustrasse 7 Tel: +49 30 84185-184
D-14195 Berlin-Dahlem, GERMANY Fax: +49 30 84185-107
Max-Planck-Institut fuer Gravitationsphysik Albert-Einstein-Institut
Am Muehlenberg 1 Tel: +49 (331) 567-7115
D-14476 Golm bei Potsdam Fax: +49 (331) 567-7298
Center for Computation & Technology at Louisiana State University
300 Frey CSC Building, Laboratory for Creative Arts and Technology
Baton Rouge, Louisiana 70803, USA Tel: +1 225 578 7150
More information about the Developers