我在代码中包含了 math.h 并使用了 -lm,但是当我使用 gcc 调试器处理 atan2() 时,我得到以下结果:
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
我的代码是
#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);
}
最佳答案
尽我所能,通过在调试器中在 result = atan2(x,y) * val;
行之前输入 step
来告诉 gdb进入 atan2
函数,如果您没有源代码,该函数将无法工作。您可能不需要调试 atan2
,因此 next
可能是您想要的命令。
如果您在此之后继续单步执行,那么当您点击 printf 时,您会遇到类似的错误,因为您也无法单步执行。如果您确实想在库函数上运行调试器,这里有一些讨论:http://ubuntuforums.org/showthread.php?t=1374829
关于c - gcc 中的 atan2() 奇怪行为,w_atan2.c : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23374526/