Blitz logo

Blitz Support :

From: Andreas R. (andreasreifschneider_at_[hidden])
Date: 2004-12-04 10:09:18


cao wrote:
>
>
> I am a newbie to blitz.
>
> I had succeeded in compiling blitz src, blitz-0.8, and obtained the
>
> library file, blitz.lib under VC++.net 2003 standard on winxp. Then I
> downloaded the example
>
> program named rangexpr.cpp from homepage of blitz++ for test but errors
> occurred,
>
>
>
> error : M_PI not define.
>
> error C2679: binary operator ‘ * ’ …
>
> on the line in the program as below,
>
> Vector<float> x=cos(Range(0,7)*(2.0 * M_PI / 8);
>
>
>
> Where is M_PI defined?
>
> I make sure that searching path of header files of blitz is included by
> following step:
>
> Tools->option->Projects->C/C++ directory-> include file and move it to
>
> the top.
>
> Even I copy the library to the directory of the project I created in
> VC++.net 2003
>
> and use #pragma comment(lib,”blitz.lib”), the problem could not be solved.
>
> Could anybody give me a clue?

On Linux (FreeBSD, ...) math.h header contains:

/* Some useful constants. */
#if defined __USE_BSD || defined __USE_XOPEN
# define M_E 2.7182818284590452354 /* e */
# define M_LOG2E 1.4426950408889634074 /* log_2 e */
# define M_LOG10E 0.43429448190325182765 /* log_10 e */
# define M_LN2 0.69314718055994530942 /* log_e 2 */
# define M_LN10 2.30258509299404568402 /* log_e 10 */
# define M_PI 3.14159265358979323846 /* pi */
# define M_PI_2 1.57079632679489661923 /* pi/2 */
# define M_PI_4 0.78539816339744830962 /* pi/4 */
# define M_1_PI 0.31830988618379067154 /* 1/pi */
# define M_2_PI 0.63661977236758134308 /* 2/pi */
# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif

This macros can be normally used as long as -ansi compatibility option isn't used.

You can solve the problem by defining the macro if it is not already defined:
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif