Make sure you've got a prototype for acos() in scope (ie, you're including
math.h). That's all I can think of for the moment. Does compiling with -Wall
tell you anything?
: suede:8; cat x.c
#include <stdio.h>
int main(int argc, char *argv[])
{
double x = acos(0.0);
printf("acos(0.0) = %f\n", x);
exit(1);
}
: suede:8; gcc -Wall -o x x.c -lm
x.c: In function `main':
x.c:5: warning: implicit declaration of function `acos'
: suede:8; ./x
acos(0.0) = 0.000000
: suede:8; cat x1.c
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
double x = acos(0.0);
printf("acos(0.0) = %f\n", x);
exit(1);
}
: suede:8; gcc -Wall -o x x1.c -lm
: suede:8; ./x
acos(0.0) = 1.570796
J