I am trying to use the Constant M_LN2 from the math.h library but always seem to get a compiler error. The code is:
#include <stdio.h>
#include <math.h>
int main(){
double x = M_LN2;
printf("%e",x);
return 0;
}
compiling with gcc on ubuntu
gcc -std=c99 lntester.c -o lntester -lm
getting output:
error: 'M_LN2' undeclared
any help in understanding why this is happening would be greatly appreciated.
As stated below the if def were not getting defined and using gcc and c99 were causing the issue. Below is the compile code that solved the issue and allowed me to use c99.
gcc -std=c99 -D_GNU_SOURCE lntested.c -o lntester -lm