The predefined constant M_PI seems to be missing from my machines copy of math.h.

Q

The predefined constant M_PI seems to be missing from my machines copy of math.h.

✍: Guest

A

That constant (which is apparently supposed to be the value of pi, accurate to the machine's precision), is not standard; in fact a standard-conforming copy of should not #define a symbol M_PI. If you need pi, you'll have to define it yourself, or compute it with 4*atan(1.0) or acos(-1.0). (You could use a construction like
#ifndef M_PI
#define M_PI 3.1415926535897932385
#endif

to provide your own #definition only if some system header file has not.)

2015-06-24, 778👍, 0💬