0

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);

}
4

2 回答 2

1

尽我所能,通过在您告诉 gdb 进入该函数step的行之前输入调试器,如果您没有源代码,该函数将无法工作。您可能不需要调试,因此可能是您想要的命令。result = atan2(x,y) * val;atan2atan2next

如果在此之后继续单步执行,您在点击 printf 时会遇到类似的错误,因为您也无法单步执行。如果你真的想在库函数上运行调试器,这里有一些讨论:http: //ubuntuforums.org/showthread.php?t= 1374829

于 2014-04-29T21:27:28.833 回答
0

你可能想试试这个...

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;

}

希望这会有所帮助,顺便看看 Mathinline.h,您将能够编写应该更小的数学函数。这里也是atan...

long double ATAN(long double RADIANS) { 注册 long double 结果;

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

}

于 2014-12-07T12:45:20.803 回答