D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\SVD\SVDBase.h:150: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
时间: 2024-01-24 12:17:36 浏览: 112
这个错误可能是因为您在代码中使用了 `std::abs` 函数,但是有另一个名为 `abs` 的函数与其冲突了。建议您使用 `std::abs` 代替 `abs`,或者使用 `using namespace std;` 来避免命名冲突。例如:
```cpp
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long int x = -123456789;
cout << abs(x) << endl; // 冲突
cout << std::abs(x) << endl; // 使用 std::abs
return 0;
}
```
如果您仍然想使用 `abs` 函数,您可以将其重命名为其他名称,如:
```cpp
#include <iostream>
#include <cmath>
namespace mymath {
using std::abs;
}
int main() {
long long int x = -123456789;
cout << abs(x) << endl; // 冲突
cout << mymath::abs(x) << endl; // 重命名为 mymath::abs
return 0;
}
```
相关问题
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\SVD\BDCSVD.h:416: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
这个错误是因为在你的代码中使用了 `std::abs` 函数,而该函数已经被 `BDCSVD.h` 文件中的另一个声明所覆盖。解决方法有两种:
1. 使用 `std::fabs` 代替 `std::abs`。
2. 在 `#include` `BDCSVD.h` 之前加上 `#undef abs`,这样可以取消 `BDCSVD.h` 中对 `abs` 的定义。
D:\ZBY\CodeBase\eigen-3.4.0\Eigen\src\LU\FullPivLU.h:715: error: conflicting declaration of C function 'long long int std::abs(long long int)' using std::abs; ^
这个错误是因为在你的代码中使用了 `std::abs` 函数,但是它与 `long long int` 类型存在冲突。解决这个问题的方法是使用 `<cmath>` 头文件中的 `llabs` 函数来代替 `std::abs` 函数,`llabs` 函数可以处理 `long long int` 类型的整数。
你只需要将代码中的 `std::abs` 改为 `llabs` 即可,例如:
```
long long int x = -12345;
long long int y = llabs(x);
```
如果你需要使用 `std::abs` 函数来处理其他类型的数据,你可以使用类型转换来解决冲突,例如:
```
int x = -12345;
long long int y = std::abs(static_cast<long long int>(x));
```
阅读全文
相关推荐
















