#include <stdio.h>
#include <math.h>
int main()
{
// printf ("isnan(0.0) : %d\n",isnan(0.0));
// printf ("isnan(1.0/0.0) : %d\n",isnan(1.0/0.0));
// printf ("isnan(-1.0/0.0) : %d\n",isnan(-1.0/0.0));
// printf ("isnan(sqrt(-1.0)): %d\n",isnan(sqrt(sqrt(-1.0))));
// printf ("isnan(sqrt(-1.0)): %d\n",isnan(sqrt(floor(-1.0))));
// printf ("isnan(-1.0/0.0)): %d\n",isnan(-1.0/0.0));
// printf ("isnan(sqrt(-1.0)): %d\n",isnan(sqrt(floor(sqrt(-1.0)))));
printf ("isnan(1/0): %d\n",isnan(1/0));
// printf ("isnan(sqrt(-1.0)): %d\n",isnan(sqrt(-1/0)));
return 0;
}
我遇到了这个错误:
我
snann.c:23:28: error: non-floating-point argument in call to function ‘__builtin_isnan’
printf ("isnan(1/0): %d\n",isnan(1/0));
问题是什么?
isnan 可以很好地处理其他输入(我评论过的那些)。
我需要解决这个问题,因为我在编译GNSS-R软件时,也遇到了这个错误。
欢迎提出任何建议。
最佳答案
问题是您向 isnan
提供了一个非浮点参数,正如它所说。
当我们翻到 the documentation ,我们看到:
Determines [whether] the given floating point number arg is a not-a-number (NaN) value. The macro returns an integral value.
1
是一个整数,0
是一个整数,所以1/0
是一个整数。
所以,您使用的宏错误,如果 GNSS-R 执行 isnan(1/0)
,那么 GNSS-R 也是错误的。
实际上,由于整数除以零,您的整个程序的行为是未定义的,但这是另一个问题!
关于c++ - 错误 : non-floating-point argument in call to function ‘__builtin_isnan’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50153410/