Question

I have included in my code the math.h and also used -lm but when i use the gcc debugger when it comes to atan2() i get the following:

16      result = atan2(x,y) * val;

(gdb) 

__atan2 (y=15, x=32) at w_atan2.c:31
31  w_atan2.c: No such file or directory.
(gdb) 

34  in w_atan2.c

(gdb) 

__ieee754_atan2_sse2 (y=15, x=32) at ../sysdeps/ieee754/dbl-64/e_atan2.c:92

my code is

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.14159265


main(){

    double x, y, val, result;

    val = 180 / PI;
    x = 15;
    y = 32;

    result = atan2(x,y) * val;
    printf("%lf\n",result);

}
Was it helpful?

Solution

As best I can figure it out, by typing step into the debugger before the line result = atan2(x,y) * val; you're telling gdb to step into the atan2 function which will not work if you don't have the sources. You probably don't need to debug atan2 so next is probably the command you want.

If you continue stepping after that you'll encounter a similar error when you hit printf, because you also can't step into that. If you really wanted to get into running the debugger on the library functions, there is some discussion here: http://ubuntuforums.org/showthread.php?t=1374829

OTHER TIPS

You may want to try this...

long double ATAN2(long double Y, long double X) { register long double VALUE;

    __asm__ __volatile__("fpatan\n\t": "=t" (VALUE) : "0" (X), "u" (Y) : "st(1)");
    return VALUE;

}

hope this helps and by the way have a look inside the Mathinline.h and you will able to write your Math functions which should be smaller. also here is atan...

long double ATAN(long double RADIANS) { register long double RESULT;

    __asm__ __volatile__("fld1\n\t" "fpatan\n\t": "=t" (RESULT) : "0" (RADIANS) : "st(1)");
    return RESULT;

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top