In addition to M_PI definition missing, recall that the following only defines a double constant.
#ifndef M_PI
#define M_PI 3.141592653589793238462643383279502984
// 1 23456789 123456789 123456789 1234567
#endif
Even though the 3.14159... in code is good for about 113-bits, the precision typically becomes 53-bit as it is a double constant.
This can be quite important for long double objects and math.
Be sure to use L when declaring a long double constant
#include <math.h>
#include <stdio.h>
#ifndef M_PI
#define M_PI 3.141592653589793238462643383279502984
#endif
#define M_PI_L 3.141592653589793238462643383279502984L
#define T(s) #s
#define S(s) T(s)
int main() {
printf("acos(-1): %.*g\n", DBL_DECIMAL_DIG, acos(-1));
printf("M_PI(string): %s\n", S(M_PI));
printf("M_PI(double): %.*g\n", DBL_DECIMAL_DIG, M_PI);
printf("M_PI(long double): %.*Lg\n", LDBL_DECIMAL_DIG, (long double) M_PI);
printf("acosl(-1): %.*Lg\n", LDBL_DECIMAL_DIG, acosl(-1));
printf("M_PI_L(string): %s\n", S(M_PI_L));
printf("M_PI_L(long double): %.*Lg\n", LDBL_DECIMAL_DIG, M_PI_L);
}
Sample output:
acos(-1): 3.1415926535897931
M_PI(string): 3.1415926535897932384626433832795
M_PI(double): 3.1415926535897931
M_PI(long double): 3.141592653589793116
acosl(-1): 3.14159265358979323851
M_PI_L(string): 3.141592653589793238462643383279502984L
M_PI_L(long double): 3.14159265358979323851